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.
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
class_namespaces-0.3.6.tar.gz
(5.8 kB
view hashes)
Built Distribution
Close
Hashes for class_namespaces-0.3.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46cb50b5e83829408ebc0faee7e975e963034c0576ee8b9bd867236247d24d96 |
|
MD5 | de62cdfc4fa6489b992916fabe165dba |
|
BLAKE2b-256 | 02b27e85afbb6cadb247a8259110704608cdbd2ab8f07b005da2b136f6c27ba9 |