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.4.tar.gz (11.4 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.4-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for class_namespaces-0.5.4.tar.gz
Algorithm Hash digest
SHA256 3ff77fe9540a8b151800162369b7d78428c9bc781b0cc067aa3f5f76f2f19b65
MD5 a8de5c805850f6caaf5705679a1c7f2b
BLAKE2b-256 41cf7a30961ed6baca9a6ea7a882864daae855a03bbeea7aef357bd080dbbcf2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for class_namespaces-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b41a3685c11ea7e81e364f05415a63a37e59392becd55b7917c321ee3388dd84
MD5 3382f546c0ae4636d3007fea489d7095
BLAKE2b-256 b6fcc29a120641bfcdf5206b64f3b9413d189a13c2c47a55e1d730f7b1f509bb

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