This small package is used to import at module level instead of package level.
Project description
importpy
This small package is used to import at module level instead of package level. It can also replace the standard import mechanism. Additionally, it has the ability to solve the relative import problem that occurs when executing unit modules located in each subdirectory without sys.path.
History
2025/07/11 v0.1.0 : initial released
Installation (pip install)
python -m pip install importpy
Features
. importing modules using relative paths
. importing modules using absolute paths
. importing member functions from modules
. support lazy-import avoid circular importing
. support to import functions from module, like from x import y ...
Examples
import importpy
aaaa = importpy('aaaa.py')
aaaa = importpy('./aaaa.py')
bbbb = importpy('../util/test/bbbb.py')
bbbb = importpy('../util/test/bbbb.py', '*')
cccc = importpy('c:/project/cccc.py')
lazy_on = importpy('lazy_on.py', use_lazy = False) # default action
lazyoff = importpy('lazyoff.py', use_lazy = True)
a_member_of_x, b_member_of_x = importpy('./pathto/x.py', 'a_member_of_x', 'b_member_of_x')
x, a_member_of_x, b_member_of_x = importpy('./pathto/x.py', '*', 'a_member_of_x', 'b_member_of_x')
ClassA, ClassB = importpy('./pathto/impl.py', 'ClassA', 'ClassB)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file importpy-0.1.0.tar.gz.
File metadata
- Download URL: importpy-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc0e9071fc3452337f4ee7de83ffcab279e9e0924d7081bc210e81ae63c3c89c
|
|
| MD5 |
34130d6877a80e5829183c9e65a1f9e6
|
|
| BLAKE2b-256 |
63efff63a9d2e3bd96eea9fae71e452e8ac284533e9848aa286698a7f77fe2c2
|
File details
Details for the file importpy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: importpy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaeada940b0d8645103d7b7e72f964e31621909a72031f033c1848e4db2be147
|
|
| MD5 |
59097a49ef56400686e7c0cda1c2b3be
|
|
| BLAKE2b-256 |
3654ad833ff840c8a0e4fef8365c0287e2b5daa41a0d8a2e9ddee0bf30b07d75
|