bag contains code for many purposes, which I find myself reusing in
multiple programs – so this code must be version-controlled.
I use SQLAlchemy and Pyramid a lot.
Documentation is at http://docs.nando.audio/bag/latest/
The library, tested on Python 3.4 and 3.5, is hosted at
where you can do your bug reports and pull requests.
- bag 0.8.0 is the last version that supported Python 2.6.
- bag 0.9.0 is the last version that supported Python 2.7.
Many modules probably still work with Python 2.7, but I do not intend to
bother testing on Python 2 anymore.
This version of bag was published with
Most important library contents
– The infamous csv Python module does not support unicode; problem solved.
– Import CSV and Excel spreadsheets based on headers on the first row.
There is also a buffered CSV writer for outputting CSV in a web app.
– The ultimate functions for email validation and
domain validation, as well as an email address harvester.
– A Path subclass that does what pathlib doesn’t do.
– Use argh to dispatch to subcommands with their command-line arguments.
– Advanced flash messages for any web framework. Also provided is Pyramid integration.
jquery templates. Includes
order, and require them from different parts of your code.
If you use the Pyramid web framework
– Deletes git branches that have already been merged onto the current branch.
Optionally, filter the branches by age (in days).
– Reorders .po files (usually after transifex messes up the order of the
translations in them) so the diff is always readable.
Less important library contents
– Verifies reStructuredText content for correctness.
– Functions for user interaction at the console.
– Read image files and do something if they are corrupt.
– Tools for finding duplicate files using hashes.
– Convenient logging initialization.
- bag.html – Encode and decode HTML and XML entities.
– Memoize decorator with a LRU (least recently used)
cache, which can take a keymaker function as an argument.
- bag.more_codecs – Got text in some weird encoding that
Python doesn’t know? OK, use iconv to decode it.
– Don’t leave your user wondering if your program is hanging;
print the progress every few seconds.
– Functions that use streams (open files).
– Functions for working with unicode strings.
– Contains lists of nouns and adjectives and can generate a random combination words
– good for generating funny test data.
– Functions to make it easier to work with datetimes.
Includes a JSON encoder that supports time, datetime and Decimal.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.