some python utilities that may be useful to some people
- Python 100%
| utils | ||
| .gitignore | ||
| Doxyfile | ||
| LICENSE | ||
| README.md | ||
| setup.py | ||
Python Utilities I wrote
This repository contains a few python utilities I think may be useful to some people, but really they're mostly funny coding exercises I posed myself.
They do things like make a callable strict (that is, only allow it to accept and return the types given in its annotations, if those exist) (see utils.decorators.strict)
modules
Currently I have some decorators, some things to do with types, and a cache module
decorators
overloadallows you to specify different implementations of a function based on the types given to itstrictallows you to make a function strict, as described abovetemplateallows you to make a "class template", as seen in C++ (except of course, everything in python happens at runtime, including type creation)convertallows you to convert any or all arguments to a function using converter function annotationsfactorylets you specify factory functions for function parametersauto_slotscreates a__slots__class attribute from assignments in the class'__init__methodcontractslets you check functions' contracts at runtime, erroring if they are not obeyed (both preconditions and postconditions can be checked)evaluatedimmediately evaluates the decorated function with given arguments
types
NaturalNumberandStrictNaturalNumber- my own
isinstancefunction that lets you checkUniontypes as well
cache
- a cache decorator that lets you specify a cache policy at function call time