Class Namespaces
Project description
Well-behaved class namespacing in Python. Inspired by https://erezsh.wordpress.com/2008/06/27/namespaces-lets-do-more-of-those-python-hackery/
Basic Usage
Example code:
import class_namespaces as cn class MyCls(cn.Namespaceable): var = 1 with cn.Namespace() as my_ns: var = 2 assert MyCls.var == 1 assert MyCls.my_ns.var == 2
Other things that work:
Descriptors (methods, classmethods, staticmethods, properties, custom descriptors)
super()
Prepopulating Namespaces. The constructor takes the same arguments as a dict.
Things that don’t work:
Combining with nearly any other metaclass.
Various ways of putting a Namespace in a Namespace that I didn’t see an obvious way to handle. In particular…
There is no way to put an established namespace directly into another namespace.
Things that might work:
New namespace features in Python 3.6. Current testing is spotty.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for class_namespaces-0.5.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b72d19712d6ee3a675bb3d5bddf1244f0187343f5ea64bb58ffd11762ecb50c1 |
|
MD5 | 2a1a27b8fe151af00014ca7dd9663adc |
|
BLAKE2b-256 | 218c34cfa9f86a5a6d53f624c4d21eda5f30b5d5892dab71c2c58cac56463ebb |