Skip to main content

import autoload

Lines of code Downloads Statistic GitHub

What is autoloading?

Autoloading means the automatic loading of the files required for your module. That is including the files required for your application without explicitly including each file with from modulename import filename construct.

1. problem

  • let directory struct be like
main.py
project_dir/
|-- example.py
|-- README.md
|-- setup.py
|-- test_package
|   |-- __init__.py
|   |-- package_file_0.py
|   |-- package_file_1.py
|   |-- package_file_2.py
  • and code
"""example.py"""
from test_package import package_file_0
from test_package import package_file_1
...
from test_package import package_file_n

but we are too lazy to type a lot letters

2. solution

  • install
pip install -UIv "import-autoload>=0.2.4a"
  • add two lines to __init__.py
"""__init__.py"""
from autoload import autoload

__all__ = autoload()
"""example.py"""
from test_package import *
  • or variant
"""main.py"""
from autoload import autoload

autoload("project_dir.test_package", pattern="package_file_[0123]")

parameters

  1. module_name path to module dir with dot separator, like in from module_name import, default current module
  2. pattern like in fnmatch(filename, pattern), default *.py

attention

  • it seems to require python version >= 3.4. if you were able to test an early version, please contact me

how it work

  • checks path to module and call importlib.import_module()

License

  • It's opensource and free software, see the LICENSE for more details

similar projects

TODO

  • handle system path separator for module_name

Metadata

Release files for import-autoload 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for import-autoload 0.3.1
File Interpreter ABI Platform Actions
import_autoload-0.3.1-py3-none-any.whl Python 3 none any Details for import_autoload-0.3.1-py3-none-any.whl

Release files / import_autoload-0.3.1-py3-none-any.whl

Download URL import_autoload-0.3.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34bcf7964612430c4b2403ea2b4f4ed5033cac3d19edf64c021d6c3adc60ab83
BLAKE2b-256 checksum
How to use checksums
2701f411ceee8a0f30601faa11b2228784171f813077e10173ffb7fc34cb0c6d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Security for import-autoload 0.3.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page