https://github.com/msoedov/klass
https://github.com/msoedov/klass
dataclasses python
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/msoedov/klass
- Owner: msoedov
- Created: 2018-05-10T01:46:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-26T15:16:41.000Z (almost 8 years ago)
- Last Synced: 2025-03-04T07:15:15.774Z (over 1 year ago)
- Topics: dataclasses, python
- Language: Python
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
### Klass
Fast, extensible and lightweight dataclasess for Python 2 /3
```python
>>> class A(Klass(a=1, b=2)):
pass
>>> A.a
1
>>> cl = Klass(a=1, b=2)
>>> cl(a=3).a
3
>>> cl(g=3)
Traceback (most recent call last):
...
NameError: Unkown argument g=3
>>> cl(a=3) == cl(a=3)
True
>>> cl(a=2) == cl(a=3)
False
>>> cl() in {cl(): 1}
True
>>> cl(a=4) in {cl(a=5): 1}
False
>>> cl()
&data._({'a': 1, 'b': 2, '__data__': ['a', 'b']})
```