Skip to main content

importing a module by physical file path

Project description

Importing a module from physical file path.


these files are existed, then..

$ tree
├── a
│   └── b
│       └── c
│           └──

4 directories, 3 files


name = "foo"
_age = "*secret*"
from magicalimport import import_from_physical_path

# importing as the module named foo2
foo = import_from_physical_path("./a/b/c/", as_="foo2")

# cached in sys.modules, so it is ok.
import foo2

here option

from magicalimport import import_from_physical_path

import_from_physical_path("", here="/tmp/foo", as_="bar")

star import

from magicalimport import import_from_physical_path
from magicalimport import expose_all_members

# something of like a `from foo import *`
print(name)  # "foo"
# print(_age)  # NameError.. because expose_all_members() doesn't expose the symbols started by "_"

# or
from magicalimport import expose_members
expose_members(import_from_physical_path("./a/b/c/"), members=["_age"])
print(_age)  # "*secret*"


  • ns option in import_symbol


  • here option is supported


  • python2 support


  • first release

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
magicalimport-0.4.0-py2.py3-none-any.whl (4.9 kB) Copy SHA256 hash SHA256 Wheel 3.5
magicalimport-0.4.0.tar.gz (3.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page