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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: clsprop-1.3.1.tar.gz
  • Upload date:
  • Size: 1.6 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.1.tar.gz
Algorithm Hash digest
SHA256 490936e71a7f11c3a201f4195cf420560d2f03c855af90dffae5370c88f272f8
MD5 7d1574f4fc001d4d40ce746446faf1f7
BLAKE2b-256 89c2fc7141e7c9892eef7d1676bda2822b2bc33c54177058d6620a2aa99bd731

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clsprop-1.3.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 627599a07867c2476f141c1494653ae26dd58e15e6374df76542cdd25e1d5870
MD5 2ea5f05053f031e7a0a6583eacfdb151
BLAKE2b-256 22472d0774bc3a28706807f8e40183cdc2683ebd199e022c09d7a67f10cd74a4

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