Skip to main content

Python import extension metaclass.

Project description

iext

PyPI - Version PyPI - Python Version tests pdm-managed pre-commit Code style: black Imports: isort

Add new imports tied to a specific class.

Installation

Install this package via pip:

python -m pip install iext

Usage

To extend the imports within a specific class, subclass ExtendImports and add an __imports__ method with all the extra imports. Everything imported here will be added to the namespace of self.

from iext import ExtendImports

class ExampleClass(ExtendImports):
    def __imports__(self):
        import pkg1
        from pkg2 import thing

    def example_method(self):
        return self.pkg1.func(self.thing)

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

iext-1.0.0.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

iext-1.0.0-py3-none-any.whl (3.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