importing a module by physical file path
Project description
Importing a module from physical file path.
examples
these files are existed, then..
$ tree
.
├── a
│ └── b
│ └── c
│ └── foo.py
└── main.py
4 directories, 3 files
a/b/c/foo.py
name = "foo"
_age = "*secret*"
from magicalimport import import_from_physical_path
# importing foo.py as the module named foo2
foo = import_from_physical_path("./a/b/c/foo.py", as_="foo2")
print(foo.name)
# cached in sys.modules, so it is ok.
import foo2
print(foo2.name)
star import
from magicalimport import import_from_physical_path
from magicalimport import expose_all_members
# something of like a `from foo import *`
expose_all_members(import_from_physical_path("./a/b/c/foo.py"))
print(name) # "foo"
# print(_age) # NameError.. because expose_all_members() doesn't expose the symbols started by "_"
# or
from magicalimport import expose_members
expose_all_members(import_from_physical_path("./a/b/c/foo.py"), members=["_age"])
print(_age) # "*secret*"
0.2
python2 support
0.1
first release
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
magicalimport-0.2.tar.gz
(2.6 kB
view details)
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 magicalimport-0.2.tar.gz.
File metadata
- Download URL: magicalimport-0.2.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47a8d189a06e95465335abbf4dd17f974948db01606d7199642581eb4bd98ab7
|
|
| MD5 |
641c4a6f8f241b712fa2da89cb9868af
|
|
| BLAKE2b-256 |
7869762df02ccc76190bb8a72c355feb2357edb1698e6acc85934bf2923dd616
|
File details
Details for the file magicalimport-0.2-py2.py3-none-any.whl.
File metadata
- Download URL: magicalimport-0.2-py2.py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0098872ee4873d365aef7156402c9548f3c97c51ef374ffed99030c874050088
|
|
| MD5 |
5c9e2ae9fa6f4469ce787a22286afe50
|
|
| BLAKE2b-256 |
fd5129e12e7219c5d03e33068d300fc914ad3e54ffbb323e1a5d838ab8e3b56c
|