https://github.com/gsllchb/dotdot
Make it easy to import the modules in parent directories
https://github.com/gsllchb/dotdot
importation library python utility
Last synced: 11 months ago
JSON representation
Make it easy to import the modules in parent directories
- Host: GitHub
- URL: https://github.com/gsllchb/dotdot
- Owner: Gsllchb
- License: mit
- Created: 2019-02-01T04:57:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-31T09:19:59.000Z (over 4 years ago)
- Last Synced: 2024-10-14T20:10:55.331Z (over 1 year ago)
- Topics: importation, library, python, utility
- Language: Python
- Size: 17.6 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DotDot
___Make it easy to import the modules in parent directories___
[](https://pypi.org/project/dotdot)
[](https://github.com/Gsllchb/DotDot/blob/master/LICENSE.txt)
If you want to solve `ValueError: attempted relative import beyond top-level package`, **DotDot** may be helpful for you.
## Installation
If it can be installed and imported successfully, it should work correctly.
Install via **pip**:
```console
pip install dotdot
```
## Example
```
root dir
├── apple.py *****************
│ * import dot *
│ * import dir.boy *
│ * import dir.subdir.cat *
│ * script code ... *
│ **************************
│
└── dir
├── boy.py *******************
│ * import dotdot *
│ * import apple *
│ * import dir.subdir.cat *
│ * script code ... *
│ **************************
│
└── subdir
└── cat.py *******************
* import dotdotdot *
* import apple *
* import dir.boy *
* script code ... *
**************************
```
## How It Works
DotDot does this magic by changing `sys.path[0]` in __import time__.