Skip to main content

A python package to import files from an adjacent folder

Project description

EasyImports

About

EasyImports is a python package that allows users to easily access and import files from sister folders:
f.ex:

- Project
    - Folder 1
        -main.py
    - Folder 2
        -userpackage1.py
        -other_stuff.py
    - My Folder 
        -important_package.py

if you would try to import anything in main.py that isn't in Folder 1 you'll get an error.
F.ex:

in main.py

import userpackage1
from Folder 2 import other_stuff.py
import My Folder.important_package.py

=> Each of these will raise a ModuleNotFoundError
With EasyImports this can be fixed.

Installing

To install EasyImports:

pip install EasyImports

Loading Imports

Inside main.py, type the following code:

from EasyImports import easyimports
easyimports.loadImports()

Now, you can just import the files userpackage1.py, other_stuff.py and important_package.py like you would normally:

#import EasyImports and load sister files
from EasyImports import easyimports
easyimports.loadImports()

#import files
import userpackage1
import other_stuff
import important_package

#alternatively, you can also do
import userpackage1, other_stuff, important_package

Pylance error

Sometimes, Pylance can raise a warning: Import "package" could not be resolved
this isn't problematic, as the program will still run without issues, but it may be visually annoying
you can fix this by ignoring the Pylance error:

#import EasyImports and load sister files
from EasyImports import easyimports
easyimports.loadImports()

#import files and ignore warning 
import userpackage1 #type: ignore

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

EasyImports-0.0.3.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

EasyImports-0.0.3-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file EasyImports-0.0.3.tar.gz.

File metadata

  • Download URL: EasyImports-0.0.3.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for EasyImports-0.0.3.tar.gz
Algorithm Hash digest
SHA256 73f53ade931cc9070277f505d537e582d8cc479f573c84769a5c07227e51a19f
MD5 dc55d3f3becd4aa73036b0a46184a40a
BLAKE2b-256 c1d49301b1d3af8af2a60c58c70d6859837e907307b8402c1b33efb86b9c3d54

See more details on using hashes here.

File details

Details for the file EasyImports-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: EasyImports-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for EasyImports-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9480fce2cc67693c093cf2497a926cd7d7b50e0d1bb8410519d4007a42dd3016
MD5 5304f84048860f8a83f547d3c5a6c80e
BLAKE2b-256 ba5ee7dc8e529866218bdf65ea01ff652ebffe2c23a18bf1555722587c3bc9a5

See more details on using hashes here.

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