https://github.com/altvod/classical
Convenience tools for working with Python classes
https://github.com/altvod/classical
class-tools dataclasses descriptors fields python python3
Last synced: 8 months ago
JSON representation
Convenience tools for working with Python classes
- Host: GitHub
- URL: https://github.com/altvod/classical
- Owner: altvod
- License: mit
- Created: 2017-03-07T23:57:43.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-11-04T11:47:54.000Z (over 4 years ago)
- Last Synced: 2025-07-14T23:49:32.802Z (9 months ago)
- Topics: class-tools, dataclasses, descriptors, fields, python, python3
- Language: Python
- Homepage:
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
=========
classical
=========
Convenience tools for working with Python classes.
Simplified subclassing:
.. code-block:: python
from classical import argumented_subclass
class MyClass:
def __init__(self, *args, **kwargs):
pass # do whatever
# subclass with presets
MySubClass = argumented_subclass(MyClass, 'MySubClass', arg1='value', arg2=4)
Various descriptors:
.. code-block:: python
from classical import ArgumentedSubclass, AutoProperty
class Thing:
Red = ArgumentedSubclass(color='red')
book = AutoProperty(has='pages')
def __init__(self, color: str = None, has: str = None):
self.color = color
self.has = has
Thing.Red # is a subclass of Thing and is 'red'
Thing.Red.book # is an instance of Thing (and Thing.Red), is 'red' and has 'pages'
See the full documentation at http://classical.readthedocs.io/en/latest/
Installation
~~~~~~~~~~~~
.. code-block:: bash
pip install classical
Testing
~~~~~~~
.. code-block:: bash
make test
You may need to install ``[fielded,testing]`` extras to run tests
Generating docs
~~~~~~~~~~~~~~~
.. code-block:: bash
make docs
You may need to install ``[fielded,docs]`` extras to generate docs