Project Scaffolding for Python

 python-logo.pngOver the summer I went through Zed Shaw’s Learn Python the Hard Way in an effort to broaden my horizons and start learning languages beyond C#.

Learn Python the Hard Way is a book designed for people with no programming experience whatsoever, but even as an experienced software developer I got a lot of value out of it. Zed does a great job forcing the reader to develop Python muscle memory early, and he introduces concepts like unit testing in Python and package management from the beginning.

One of the really valuable lessons of Learn Python the Hard Way is in exercise #46, where Zed recommends a great generic folder and file structure for new Python projects, like this one:


This is a great starting point for most Python projects, as it allows you to easily build a Python package with setuptools and to unit test it (using Nose in this case.)

However, I really didn’t like having to manually copy and rename folders / files constantly in order to work with this project structure, so I wrote my own Python package called “Scaffold” which allows you to automatically scaffold new projects with this structure directly from the Python command line, like this:

python -m scaffold -p "projectname" [-d {base directory}]

And with that, you’ll automatically generate the Python project structure I showed you previously, with Nose set up as the default unit testing framework.

Installing Scaffold

Scaffold is compatible with Python 2.7 – I haven’t tested it with Python 3.0+, but I’d be surprised if there were compatibility issues with it given Scaffold’s simplicity.

You can install Scaffold directly via Pip:

pip install scaffold

If you have more questions about Scaffold and its usage, please see the scaffold-py readme on Github.

Contributing to Scaffold

You can find the source to scaffold-py on my Github account. Patches are not only welcome, but strongly encouraged!

Discussion, links, and tweets

I'm the CTO and co-founder of Petabridge, where I'm making distributed programming for .NET developers easy by working on Akka.NET and Helios.

P.S. Get the latest from Aaronontheweb

Have my most recent essays and articles delivered directly to your mailbox.