dotdot

Make it easy to import the modules in parent directories


Keywords
importation, library, python, utility
License
MIT
Install
pip install dotdot==1.1.0

Documentation

DotDot

Make it easy to import the modules in parent directories

released version license

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:

pip install dotdot

Quick Start

Consider a common project structure as following:

FooProject
    ├── foo
    │    ├── script.py
    │    └── util.py
    └── util.py

Now, script.py can import those utils by importing dotdot first. Like this:

import dotdot
import foo.util
import util

Moreover, you can import the modules in grandparent or even great grandparent directory by importing dotdotdot or dotdotdotdot first.

How It Works

DotDot does this magic by changing sys.path[0] in import time.