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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: clsprop-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b971036c250184482b8ba577e2a00b60fe17a8e799d5c73912aad2f2b9a6ef93
MD5 81301d449282a3efc307740cd8af9b82
BLAKE2b-256 3a628b3062580a92e2ddcb8af9b8496f04481957ed5250d7ccf9aae203e2a2fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clsprop-1.0.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cc84a96589e41a2d1fe5d6798c1311d459a162d36d2b30de197e5fe1f4463d03
MD5 527af04ee043d687de02b0615066f5c1
BLAKE2b-256 35980818acd5378d6349533fa682817e5f025143af90ed60338b3b9679d1102a

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