Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

registrable

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

registrable

Python module for registering and instantiating classes by name. Based on the implementation from AllenNLP.

  • 0.0.4
  • PyPI
  • Socket score

Maintainers
1

python-registrable

CircleCI License PyPI version Documentation Status

Python module for registering and instantiating classes by name. Based on the implementation from AllenNLP.

Installing

The quickest way to install is through PyPI.

pip install registrable

Usage

from registrable import Registrable

# Create a base class that inherits from `Registrable`.
class MyBaseClass(Registrable):
    def do_something(self):
        raise NotImplementedError


# Now register subclass implementations of your base class.
@MyBaseClass.register("first_implementation")
class FirstImplementation(MyBaseClass):
    def do_something(self):
        return 1


# You can access an implementation by calling `.by_name()` on the base class.
subclass = MyBaseClass.by_name("first_implementation")
instance = subclass()
assert instance.do_something() == 1

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc