Skip to content
/ DotDot Public

Make it easy to import the modules in parent directories

License

Notifications You must be signed in to change notification settings

Gsllchb/DotDot

Repository files navigation

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

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.

About

Make it easy to import the modules in parent directories

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages