🏫 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.1.0.tar.gz
(1.3 kB
view details)
Built Distribution
File details
Details for the file clsprop-1.1.0.tar.gz
.
File metadata
- Download URL: clsprop-1.1.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.9 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4509a5fb7292289ca3cc2a8fb4dc424c9ec1cd9197c85157e28d908a7044b241 |
|
MD5 | e724829ef02b2781d39621d8808bc9fd |
|
BLAKE2b-256 | a3600a4d75f7e11fe1714207e6a1d6fb9344632f1d5f8e6caa3593dd1b384da2 |
File details
Details for the file clsprop-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: clsprop-1.1.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.9 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 715e87ba10d5562762ea6de67c94724a8f8ed9c7c7251052201998875c9de785 |
|
MD5 | 5616887ff666a255b09e37790e4b5ef5 |
|
BLAKE2b-256 | bf5a2189a9000e07c83e9880fb0f43c07ae94afdee1cc486bb30fe5f07c5a492 |