https://github.com/sakryukov/python-readonly-class-attributes
Comprehensive solution for read-only Python class attributes: clear syntax, no dependency on naming conventions
https://github.com/sakryukov/python-readonly-class-attributes
class immutability python read-only
Last synced: about 1 year ago
JSON representation
Comprehensive solution for read-only Python class attributes: clear syntax, no dependency on naming conventions
- Host: GitHub
- URL: https://github.com/sakryukov/python-readonly-class-attributes
- Owner: SAKryukov
- License: mit
- Created: 2018-01-28T03:25:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-10T06:40:56.000Z (over 7 years ago)
- Last Synced: 2025-01-28T17:24:23.552Z (over 1 year ago)
- Topics: class, immutability, python, read-only
- Language: Python
- Homepage: https://www.SAKryukov.org
- Size: 28.3 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Python Readonly Class and Instance Attributes: Complete Solution
[Original publication](https://www.codeproject.com/Articles/1227368/Python-Readonly-Class-Attributes)
### Basic usage:
```
class Foo(ReadonlyBase):
bar = 100
test = Readonly.Attribute(13)
def __init__(self, a, b):
self.a = a
self.b = Readonly.Attribute(b)
```
Partially based on the code sample by [rIZenAShes](https://github.com/rIZenAShes) found [on GitHub](https://gist.github.com/rIZenAShes/8469932)