Skip to main content

Dynamically load modules from directories

Project description

py_load_modules

Description

py_load_modules is a python3 library which takes a class, and a list of directories. It will search within those directories (without any recursive searching) for classes which implement the argument class. It will return a list of instances of those classes for use.

Installation

python3 -m pip install  git+https://github.com/rhhayward/py_load_modules.git@master

Usage

Assuming a directory structure like this:

from load_modules import load_modules

modules = load_modules.load(SuperClass, ['/path/to/py_files/', 'relative_path/to/py_files'])
for module in modules:
    module.class_method()

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

load_modules-0.0.1.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

load_modules-0.0.1-py3-none-any.whl (3.1 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