/recipes

A cookbook for the python developer connoisseur 🐍🧑🏽‍🍳🍷

Primary LanguagePythonMIT LicenseMIT

recipes

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:

Extending functionality of builtins

  • 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 sets
  • op : Drop in replacement for the builtin operator module with added support for default values. And then some.

Input / Output

  • io : File tree iteration, context managers for safe input/output with file backups, flexible (de)serialization wrappers.
  • regex : Contract verbose style regexes.

Iterators / Generators

  • iter : Additional iteration utilities: cofiltering, conditional indexing.

Arrays

  • array : array folding (windowing) without memory duplication.

Functional programming

  • decorators : Extensible decorators for: Control flow (catching exceptions, fallback values), parameter/return value tracing, line profiling.
  • caches : Performant functional memoization.

API Development helpers

  • 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.

Code Introspection

  • introspect : Refactor (sort, merge, split, relativize, (de)localize etc.) import statements in python source code.

Object Oriented Tools

  • oo : singleton and null classes, context manager for temporary attributes, cached property decorator with optional dependencies, property forwarding for nested objects.

Math

  • transforms : Transforms to and from Cartesian, Spherical, Cylindrical coordinates.

Install

pip install https://github.com/astromancer/recipes.git

Use

Example

Test

The test suite contains further examples of how recipes can be used. Testing is done with pytest:

pytest recipes

Contribute

Contributions are welcome!

  1. Fork it!
  2. Create your feature branch
    git checkout -b feature/rad
  3. Commit your changes
    git commit -am 'Add some cool feature 😎'
  4. Push to the branch
    git push origin feature/rad
  5. Create a new Pull Request

Contact

License