Skip to main content

Class Namespaces

Project description

Documentation Status https://travis-ci.org/mwchase/class-namespaces.svg?branch=master https://coveralls.io/repos/github/mwchase/class-namespaces/badge.svg?branch=master https://api.codacy.com/project/badge/Grade/f73ed5e3849c4049b8c9e3f17f6589da https://ci.appveyor.com/api/projects/status/ik5ci1icjmib9fi7?svg=true https://codecov.io/gh/mwchase/class-namespaces/branch/master/graph/badge.svg Code Health Scrutinizer Code Quality Code Coverage Build Status Code Climate Test Coverage Issue Count

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


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.5.3.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

class_namespaces-0.5.3-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file class_namespaces-0.5.3.tar.gz.

File metadata

File hashes

Hashes for class_namespaces-0.5.3.tar.gz
Algorithm Hash digest
SHA256 a2af8f0380f505b1da6313fd0274bda2f931e3d1add2d30c0d01f2db3a34c70d
MD5 c6dcb8e35df117bcee4fdc9a6cc2a6f3
BLAKE2b-256 f49e270859cc05d97da7a29affcfb053a9bbf4ae7614a1e81c3a5056bdb088ea

See more details on using hashes here.

File details

Details for the file class_namespaces-0.5.3-py3-none-any.whl.

File metadata

File hashes

Hashes for class_namespaces-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f6f8fde24b79fa7f1ef588b7312a7a6030369218a0242ad7c6f7e7026f049fdc
MD5 19e285a702c7edf51da1c85a09df884c
BLAKE2b-256 4af0b66754f36862d0ce5f63afc5628e6e7d2b9e8403c268d4587d5075aa784f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page