An open API service indexing awesome lists of open source software.

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

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)