importing a module by physical file path
.. image:: https://travis-ci.org/podhmo/magicalimport.svg?branch=master :target: https://travis-ci.org/podhmo/magicalimport
Importing a module from physical file path.
these files are existed, then..
.. code-block:: bash
$ tree . ├── a │ └── b │ └── c │ └── foo.py └── main.py
4 directories, 3 files
a/b/c/foo.py
.. code-block:: python
name = "foo" _age = "secret"
.. code-block:: python
from magicalimport import import_from_physical_path
foo = import_from_physical_path("./a/b/c/foo.py", as_="foo2") print(foo.name)
import foo2 print(foo2.name)
here option ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
from magicalimport import import_from_physical_path
import_from_physical_path("bar.py", here="/tmp/foo", as_="bar")
star import ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
from magicalimport import import_from_physical_path from magicalimport import expose_all_members
from foo import *
expose_all_members(import_from_physical_path("./a/b/c/foo.py")) print(name) # "foo"
from magicalimport import expose_members expose_members(import_from_physical_path("./a/b/c/foo.py"), members=["_age"]) print(_age) # "secret"
0.9.1
0.9.0
0.8.1
0.8.0
here=__file__
on caller module.here=os.getcwd()
)0.7.3
0.7.2
0.7.1
0.7.0
0.6.0
0.5.0
0.3.0
0.2.1
0.2
0.1