🏫 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.0.tar.gz
(1.3 kB
view details)
Built Distribution
File details
Details for the file clsprop-1.2.0.tar.gz
.
File metadata
- Download URL: clsprop-1.2.0.tar.gz
- Upload date:
- Size: 1.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.0 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7355ec02f9f22570e5e2273148e12b3b166d6a2b93e3c38e7e22d41e0864edb1 |
|
MD5 | 69ba1508ab2739d31aca093ecf13d836 |
|
BLAKE2b-256 | d3f4ea41422aed542bc0559709d6d22b4bb6e358bcbc2bd19a2df2a6db6c4271 |
File details
Details for the file clsprop-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: clsprop-1.2.0-py3-none-any.whl
- Upload date:
- Size: 1.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.0 CPython/3.10.11 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f4dbd9ad635122ecc759d3e64b93d3511f2b34318aafde9d732427ce5be5304 |
|
MD5 | de76552224600d8e4c33514850dda6e4 |
|
BLAKE2b-256 | 54393a28798600fb064f72b2c195ec1b1bf003ddd736e18f196b3833bdb0e989 |