Skip to main content

Automatically log all new subclasses of a specified base class.

Project description

Motivation

This library implements a simple clas decorator that you can apply to a base class. This decorator then hooks into the way the decorated class is subclassed, adding all new subclasses to a dictionary whose keys are class names and values are the classes themselves.

The motivation for this project was to autogenerate deep learning models from pure JSON files, thus ensuring reproducibility of the results. I do, however, think that it is ideal for any kind of codebase where we want to generate safe code from configuration files.

Installation instructions

The subclass register can be installed with pip:

pip install subclass-register

by cloning this repo and running setup.py

git clone https:\\github.com\yngvem\subclass-register
cd subclass-register
python setup.py

or by simply downloading the src\subclass_register\subclass_register.py file and the LISENCE file into your project.

Example

Here is a basic example of how to use the subclass register.

from subclass_register import SubclassRegister


register = SubclassRegister('car')

@register.link_base
class BaseCar:
    pass

class SUV(BaseCar):
    def __init__(self, horse_powers):
        self.horse_powers = horse_powers

suv = register['SUV'](horse_powers = 50)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subclass-register-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

subclass_register-1.0.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file subclass-register-1.0.0.tar.gz.

File metadata

  • Download URL: subclass-register-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for subclass-register-1.0.0.tar.gz
Algorithm Hash digest
SHA256 cb619c8f4efdfbac55d3496d773837a4de6fd2db308fdcc36743b60645d7185d
MD5 19248575ad64d24f2711581a6ca65cd9
BLAKE2b-256 6eba769dcac90f5a7466903cd5da3e561a8e9b7f7cc308128c68a10c17cf110a

See more details on using hashes here.

File details

Details for the file subclass_register-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: subclass_register-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for subclass_register-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 693d4a86c016f519c207dde2ad222a732691f8e7c5748afd2e89b467fbf34fdd
MD5 a6ef55351cce3c1a46f2104c19a4acaf
BLAKE2b-256 52608ca3c22466c65fa83c194cc422c3f15d1333d885f71cd7cb90293e445841

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page