Skip to main content

Make it easy to import the modules in parent directories

Project description

DotDot

Make it easy to import the modules in parent directories

released version license downloads

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.

pip install dotdot

Quick Start

Consider a common project structure as following:

FooProject

    ├── foo

    │    ├── script.py

    │    └── util0.py

    └── util1.py

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

import dotdot
import foo.util0
import util1

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

How it work

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dotdot-0.1.0.tar.gz (2.9 kB view hashes)

Uploaded Source

Built Distribution

dotdot-0.1.0-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page