Skip to main content

Python package to import modules at runtime.

Project description

Python runtime loader (pyrulo)

Python library to import classes from script files at runtime.

Installation

pip install pyrulo

Usage

Lets say we have the following scripts

# base.py script

class Base:
  pass
# a.py script
from base import Base

class A(Base):
  pass
# b.py script
from base import Base

class B(Base):
  pass
# c.py script
from base import Base

class C(Base):
  pass

We can use pyrulo to retrieve all classes that inherits from Base in a given script path or folder

from base import Base
from pyrulo import class_imports

script_path = "a.py"
folder_path = "."

script_classes = class_imports.import_classes_in_file(script_path, Base)  # returns [A]
folder_classes = class_imports.import_classes_in_dir(folder_path, Base)  # returns [A, B, C]

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

pyrulo-0.2.7.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

pyrulo-0.2.7-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

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