https://github.com/ademakdogan/epath
Easy and dynamic import for python
https://github.com/ademakdogan/epath
Last synced: 2 months ago
JSON representation
Easy and dynamic import for python
- Host: GitHub
- URL: https://github.com/ademakdogan/epath
- Owner: ademakdogan
- License: mit
- Created: 2021-07-05T12:33:34.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-07-05T22:10:47.000Z (almost 4 years ago)
- Last Synced: 2025-03-08T05:09:33.787Z (3 months ago)
- Language: Python
- Size: 5.86 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# epath
This package provides easy and dynamic way to import parent files in Python.
Sample folder structure can be seen below.
```
--main_folder--app.py
--folder_1
--sample.txt
--folder_2
--target.py
```
Here, it is desired to read the sample.txt file from the target.py file. Then it will be used by calling the say_hello and say_goodBye functions in the app.py file.app.py
```
def say_hello():
print("Hello")def say_goodBye():
print("GoodBye")
```sample.txt
```
This is a sample.txt
```target.py
```
from epath import Pathpt = Path()
txt_path = pt.get("/../folder_1/sample.txt")
with open(txt_path) as f:
lines = f.readlines()print(lines)
>>>['This is a sample.txt ']#----------------------------------
app = pt.importer("/../app")
app.say_hello()
>>>Helloapp.say_goodBye()
>>>GoodBye```