Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A lazy source code generation library

Project Description

What is BrownBat ?

BrownBat is a pure Python library to create source code generators. By source code generator, I mean a program which outputs source code. Its main features are: * Laziness everywhere: you can set every possible name or attribute after the object has been created and used, and it will be taken into account when printed. This allows the generator to set the layout of the code, and for example set the names of the variables or functions later, when the correct name can be computed from another source of information.

  • Nifty operator overloading, making it quite easy to manipulate source code objects.
  • Automatic debugging comments for every object created. That means that when you create a variable and you print its definitionto an output source file, you will be able to tell which line in the Python generator created this variable. This is incredibly helpful when you are lost in your spaghetti code and you don’t even know from where that specific output source code line comes from, or just why this line of code shows up in the output.

It currently handles C langage, but adding new langages leveraging all the facilities given by the core should be easy.

Why would I want to generate some source code ?

Because it allows you to write custom tools to avoid repetitive or error prone tasks. A good example would be the generation of a serialization and deserialization routines for a C structure described in XML. This can be quite easily accomplished with the help of this library and the standard Python library.

Supported langages

Currently, only C langage is supported. That said, what makes this library interesting (laziness, operator overloading) is separated in a langage independent module (core), which should make it easy to add support for a new langage. A guide to write support code for new langages will be released in the next few months.


BrownBat requires Python 3 to work correctly. It can be installed from PyPI (Python package index):

> pip install brownbat

To install the beta version, use the –pre switch of pip.

Alternatively, the development version can be retrieved on Github:

How to use it ?

Documentation and guides will be made available in the next few month. It will include examples and a guide to implement support for a new langage (most of the hard work of operator overloading is inside a core module, which is langage independent).


BrownBat is licensed under the GNU Lesser General Public License v3 or later (LGPLv3+) License.

Why BrownBat is named BrownBat ?

Because those cute animals are very lazy (according to, they can sleep up to 20h a day). And this library is designed to be lazy at its very core.

Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
BrownBat-0.0b2-py3-none-any.whl (27.7 kB) Copy SHA256 Checksum SHA256 3.4 Wheel Dec 20, 2014
BrownBat-0.0b2.tar.gz (25.6 kB) Copy SHA256 Checksum SHA256 Source Dec 20, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting