Skip to main content

Automatically log all new subclasses of a specified base class.

Project description


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

git clone https:\\\yngvem\subclass-register
cd subclass-register

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


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

from subclass_register import SubclassRegister

register = SubclassRegister('car')

class BaseCar:

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.

Files for subclass-register, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size subclass_register-1.0.0-py3-none-any.whl (5.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size subclass-register-1.0.0.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page