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 throw 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 throw 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.2.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

EasyImports-0.0.2-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: EasyImports-0.0.2.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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for EasyImports-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c1bc421ca208ec1822e702778771eb5e60a706b592300dac2eba3362ea05063c
MD5 ec9c901dca4b50c414637a9c110df4e7
BLAKE2b-256 94be5b4e4101b55bb801a26c696e1f472ba9f3011f45c69f542b342e5463a21d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: EasyImports-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.7 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.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for EasyImports-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5dd56ef5c2952d441d5599ce86b5e342e13a03ef233ad8ac8f85231b62fb908e
MD5 b515959fe11834c0aa3a657a9a682eac
BLAKE2b-256 f80687fb71bc957266cd49ce1e0644271d5e7e38c0dfd858e19a158c99144694

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