4 can't-miss Python goodies from Microsoft, Google, Facebook, and Uber

These four projects let you work in Python even more easily

Open source software is already a good development, but open source software with the backing of a household name in IT is even better.

Big-name outfits work with Python due to its versatility and wide adoption. Sometimes they use it to connect service A to front end B; other times it's for creating utilities that relieve a little of the drudgery on a particular job.

Here are four recent Python projects from big-name IT vendors, ranging from the minimal to the maximal, that make life a little simpler.

YAPF

As the name imples, YAPF (Yet Another Python Formatter), from folks at Google, reformats Python code for better readability and consistency. In the words of its creators, it's meant to "end all holy wars about formatting" by providing a single, consistent method to make code presentable.

YAPF can be run as-is on an existing codebase, or it can be tweaked as needed -- for example, by running it only across a range of lines in a file, or by changing extremely specific settings, like whether to indent values listed in a dictionary. It's also possible to decorate a file with code comments to toggle YAPF formatting on or off, which can keep it from munging inline string-literal values.

Sparts

Facebook hates the drudgery associated with building services in Python -- so much so that it decided to do something about it. The company created a library, Sparts, that makes it "dead simple to write new services with little to no excess code."

Sparts provides developers with the skeleton for two basic components: a service component for the actual service itself, and a tasks component for handling offline or asynchronous jobs. Some examples include a Linux dbus service, a prototype for a chat server using the Twisted library, and a nonblocking handler.

Azure CLI 2.0

The original version of Microsoft's command-line client for Azure, the Xplat-CLI was written in JavaScript when Node.js was the hottest new thing in town. Unfortunately, it wasn't well received by users, in big part because it brought along Node's hassles.

Microsoft took the criticism to heart and rewrote the Azure CLI from the ground up in Python. The new CLI can be installed with Python's pip package manager or with a simple curl/wget command. Even if you're not an Azure user, the project can serve as a model for other CLIs. And given that it's MIT-licensed, any derivative work you create with it won't have many legal strings attached.

Pyflame

Ride-on-demand provider Uber with needed insight into how its services performed across its organization. For maximum visibility into its Python services, Uber devised Pyflame, an analyzer for running Python applications.

Pyflame was created to replace Python's native profile and cProfile modules. They work, but at the cost of noticeable overhead, plus the need to explicitly instrument the Python app in question. Pyflame plugs straight into the Python runtime using Unix's ptrace, meaning it has almost no overhead, and generates a flame graph -- thus the name -- that shows you where your app spends most of its time.


EmoticonEmoticon