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.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6f8fde24b79fa7f1ef588b7312a7a6030369218a0242ad7c6f7e7026f049fdc |
|
MD5 | 19e285a702c7edf51da1c85a09df884c |
|
BLAKE2b-256 | 4af0b66754f36862d0ce5f63afc5628e6e7d2b9e8403c268d4587d5075aa784f |