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

import clsprop

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

Uploaded Source

Built Distribution

clsprop-1.2.1-py3-none-any.whl (2.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clsprop-1.2.1.tar.gz
  • Upload date:
  • Size: 1.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0

File hashes

Hashes for clsprop-1.2.1.tar.gz
Algorithm Hash digest
SHA256 dd9dbc9a63b5d324b41db272c89828c1327fa06b2cfb19c1a6c332bae4442198
MD5 42281ff2d732d3f2bf677466dcc749c2
BLAKE2b-256 9a276bfcbc5ee6c9b3c3a0ebd6132a0646dbac7b3e08cf41201d26acb0cad3c1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clsprop-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 2.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.11 Darwin/21.6.0

File hashes

Hashes for clsprop-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae1669c358466889f976800a27750cfc136656db60ad06160bf105f780a22df8
MD5 54df02b4bd358d31d9f5d82e4beec5c5
BLAKE2b-256 c99b74910d80d7000e6255108765d4705d28d232ea9f6a07f86177b729870107

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