Skip to main content

importlib wrapper, instantiate class dynamically in one line

Project description

easily load classes from source files basically just a wrapper for importlib

why?

# doesn't look
from pyclsload import load
o = load("somefile.py", "ThisAClass")
o.somemethod()

# better than
from importlib.util import spec_from_file_location, module_from_spec
s = spec_from_file_location("ThisAClass", "somefile.py")
o = module_from_spec(s)
s.loader.exec_module()
o.somemethod()

install

pip3 install pyclsload

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

pyclsload-1.0.tar.gz (1.8 kB view hashes)

Uploaded Source

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