No project description provided
Project description
Constant Properties Protector Package
With the help of this module, you can protect some of properties in a class. Protecting means avoiding to change them but keep them publicly available.
from constant_properties_protector import CPP
class A(CPP):
def __init__(self):
CPP.__init__(self, protecteds=[
'initialized_protected',
'uninitialized_protected'
])
self._initialized_protected = 12
a = A()
print(a.initialized_protected)
# >>> 12
a.t = 2
print(a.t)
# >>> 2
a.initialized_protected += 1
# Exception: Can not modify constant property: initialized_protected
a.uninitialized_protected = 10
# Exception: Can not modify constant property: uninitialized_protected
NOTE:
- You can use
CPP
along with other base classes. CPP
will override__getattribute__
and__setattr__
. So where these functions somehow are overrided or are going to be overridden, don't use it .- Use
_
first of the protected property name to get fully access to it.
Installation
pip install constant-properties-protector
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
Built Distribution
Close
Hashes for constant-properties-protector-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ec21d8087e52ada48516bf640033c04bd8e84653ba951fcef06c437145d5e6c |
|
MD5 | 12f3d91d0a2873f6c2f851fdbe4ede3f |
|
BLAKE2b-256 | 125194858214edce2cade25e38cc44205af60bda5bc96a8cb069f95a9228d2b3 |
Close
Hashes for constant_properties_protector-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 040eff40c3bc4c2040f32b84bb0395e00647c5058ba920821b8a43ca335b5d20 |
|
MD5 | 2978afc153cf42ac8e0a14f7f42fd75b |
|
BLAKE2b-256 | e7241af37f5bf4d1a7bbc304c625e77e7c59f8faaf7738caaa809eeeb4d64bea |