python-registrable
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
Metadata
Release files for registrable 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| registrable-0.0.4.tar.gz | 4.9 kB | Without provenance | Details for registrable-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| registrable-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for registrable-0.0.4-py3-none-any.whl |
Total release size: 14.8 kB
Release files / registrable-0.0.4.tar.gz
| Download URL | registrable-0.0.4.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20bb42aeeab062432f053a788c775106e45a2fab1fdae4103df45e465086d0a3
|
|
BLAKE2b-256 checksum How to use checksums |
ba57e7a9c28426a7bcd411a77885a633de468430f1f479c043deb1254ba1da02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
|
Release files / registrable-0.0.4-py3-none-any.whl
| Download URL | registrable-0.0.4-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
475ec762101c50942f59d15256646162c497e91e6ecd1442ad9b34ada113f73c
|
|
BLAKE2b-256 checksum How to use checksums |
8a476370d9389664f1af31de4048934faeb681035a079ddc3d284a366875e755
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
|
Security for registrable 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.