Google ignites Python library for command lines

The Python Fire library, which Google has already used in its machine intelligence project, automatically converts code into a CLI

Google ignites Python library for command lines
Credit: Comfreak

With its Python Fire library, Google is offering Python developers a mechanism to easily generate command-line interfaces.

Newly available via open source, Python Fire turns code into a CLI without developers needing to do any more work, so it's easier to transition between the Bash Linux CLI and Python. Google engineers have already used Python Fire to produce CLI tools from Python libraries, including the Python Imaging Library and a tool in the Google Brain machine intelligence project that manages experiments equally from Python or Bash.

"You don't have to define arguments, set up help information, or write a main function that defines how your code is run," said Dave Bieber, a software engineer for Google Brain

Fire uses inspection to turn Python objects into a CLI that offers tab completion and documentation. Fire can be run on any object, including functions, classes, and modules. The tool can help debugging or exploring Python code and turning existing code into a CLI, and developers will find it easier to use a REPL via Fire. CLIs built with Fire come with an interactive mode. "Run the CLI with the `--interactive` flag to launch an iPython REPL with the result of your command," Bieber said.

This story, "Google ignites Python library for command lines" was originally published by InfoWorld.