Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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 Build Status 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.

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.

Project details


Download files

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

Files for dotdot, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size dotdot-1.0.1-py2.py3-none-any.whl (8.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size dotdot-1.0.1.tar.gz (3.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page