Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 23 days 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-10-31T09:19:59.000Z (about 3 years ago)
- Last Synced: 2024-10-09T09:50:15.003Z (29 days 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___[![released version](https://img.shields.io/pypi/v/DotDot.svg)](https://pypi.org/project/dotdot)
[![license](https://img.shields.io/github/license/Gsllchb/DotDot.svg)](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__.