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

Uploaded Source

Built Distribution

clsprop-1.3.0-py3-none-any.whl (2.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clsprop-1.3.0.tar.gz
  • Upload date:
  • Size: 1.5 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.3.0.tar.gz
Algorithm Hash digest
SHA256 6312d5b39acca9d53f41326dcc360e117741aa9dec6329ef1ffc89d88a7b80d5
MD5 21b1a4ec0571b4c5e2f59e6e0b5443ef
BLAKE2b-256 a6e80bfd101a94218adffbb6895ddd965f0a191c9d7389f8052e2416e927b29a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clsprop-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 2.2 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b3f96a4b0a3e6519bd066270a277c7cd066c50087c79c9b00a732700c536abf
MD5 aa551e3bf9a12237b488d4f6f4777e8a
BLAKE2b-256 f2c212b4208bb727a304187e16c748531d5c2eb245cd85a3ffefdd466e17c5fa

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