Skip to main content

🏫 Just like @property but for classes 🏫

Project description

Works just like @property for classes, except deleters don't work (and are perhaps impossible).

Inspired by https://stackoverflow.com/a/39542816/43839

Example

class Full:
    _name = 'fool'

    @clsprop
    def name(cls):
        return cls._name

    @name.setter
    def name(cls, name):
        cls._name = name

    # Unfortunately, the deleter never gets called
    @name.deleter
    def name(cls, name):
        raise ValueError('Cannot delete name')

assert Full.name == 'fool'

Full.name = 'foll'
assert Full.name == 'foll'

del Full.name  # oh, well

API Documentation

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

clsprop-1.0.0.tar.gz (1.6 kB view details)

Uploaded Source

Built Distribution

clsprop-1.0.0-py3-none-any.whl (1.9 kB view details)

Uploaded Python 3

File details

Details for the file clsprop-1.0.0.tar.gz.

File metadata

  • Download URL: clsprop-1.0.0.tar.gz
  • Upload date:
  • Size: 1.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Darwin/21.6.0

File hashes

Hashes for clsprop-1.0.0.tar.gz
Algorithm Hash digest
SHA256 41ebc33a4735c31613dc67dcbd89e8a6d2bb9ebfabe8a2d7eddd6f2998cfbff6
MD5 53dbc8b0736e69819d67cfee92fa0828
BLAKE2b-256 dd323343e7320b05e95b56b511f9b76bb0fd805f3de01d13d484d6b10def4250

See more details on using hashes here.

File details

Details for the file clsprop-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: clsprop-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.10.9 Darwin/21.6.0

File hashes

Hashes for clsprop-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb38c3d9d682917de1f522737cb4659da2337c76888c754f86011e7de9c55f8b
MD5 bdba7134ca83b872a6110beeb1bbc697
BLAKE2b-256 a3bdf9519b8e44c687a069102bdace93a72ffb56b5e1b98e49b7d8ec0eaeabd6

See more details on using hashes here.

Supported by

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