A cookbook for the python developer connoisseur 🐍 📖 🍾
This project contains a curated collection of convenient utility functions that are useful across many projects. The library extends many of the standard python module's functionalities, and is therefore similarly structured.
Here are some highlights of the available modules and their functionality:
string
: substitution, character deletion, affix editing, recasing, pluralization, bracket parsing, similarity matching, etc.lists
: cosorting, multi-indexing, conditional splitting, flattening, deduplication.dicts
: Attribute dicts, many-to-one maps, autovivification, tree-like mappings, ordered defaultdict, pretty printing, and various other mapping utilities.sets
: Ordered setsop
: Drop in replacement for the builtinoperator
module with added support for default values. And then some.
io
: File tree iteration, context managers for safe input/output with file backups, flexible (de)serialization wrappers.regex
: Contract verbose style regexes.
iter
: Additional iteration utilities: cofiltering, conditional indexing.
array
: array folding (windowing) without memory duplication.
decorators
: Extensible decorators for: Control flow (catching exceptions, fallback values), parameter/return value tracing, line profiling.caches
: Performant functional memoization.
pprint
: pretty printing!logging
: logging mixin for explicitly tracing class functionality.synonyms
: Intelligent parameter name autocorrect decorator for building flexible APIs.interactive
bash
: bash style brace expansion and contraction.
introspect
: Refactor (sort, merge, split, relativize, (de)localize etc.) import statements in python source code.
oo
: singleton and null classes, context manager for temporary attributes, cachedproperty
decorator with optional dependencies, property forwarding for nested objects.
transforms
: Transforms to and from Cartesian, Spherical, Cylindrical coordinates.
pip install https://github.com/astromancer/recipes.git
The test suite
contains further examples of how
recipes
can be used. Testing is done with pytest
:
pytest recipes
Contributions are welcome!
- Fork it!
- Create your feature branch
git checkout -b feature/rad
- Commit your changes
git commit -am 'Add some cool feature 😎'
- Push to the branch
git push origin feature/rad
- Create a new Pull Request
- e-mail: hannes@saao.ac.za
- see LICENSE