https://github.com/pavanchhatpar/python-read-only-class-attributes
A simple decorator to make a class have either some or all read-only attributes
https://github.com/pavanchhatpar/python-read-only-class-attributes
Last synced: about 2 months ago
JSON representation
A simple decorator to make a class have either some or all read-only attributes
- Host: GitHub
- URL: https://github.com/pavanchhatpar/python-read-only-class-attributes
- Owner: pavanchhatpar
- Created: 2019-12-20T18:01:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-02T00:08:43.000Z (over 5 years ago)
- Last Synced: 2025-02-18T09:36:49.584Z (3 months ago)
- Language: Python
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Read only Python Class Attributes
This package provides a decorator to make read only attributes on a given
Python class### Install
``` bash
pip install read_only_class_attributes
```### Usage
``` python
from read_only_class_attributed import read_only#example for all read only attributes
@read_only('*')
class _CONSTANTS:
pi = 3.14159
G = 6.67430e-11CONSTANTS = _CONSTANTS()
#example for some read only attributes
@read_only('pi', 'G')
class _PLANETCONSTANTS:
pi = 3.14159
G = 6.67430e-11
g = 9.18 #can change
planet = 'Earth' #can changePLANETCONSTANTS = _PLANETCONSTANTS()
```