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(metaclass=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.4.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c5d5efd707444575cdc2720f910dfd11a79b228eef0b09c032d48c7ef481465 |
|
MD5 | bb7c7e92ef61753b6143a24a393fe8d6 |
|
BLAKE2b-256 | 790c5a7595cbd20f2b624c1cee000fcaa38bec3c5300f4a565eaa1e29df383ea |