Python Forum
Relative import tool
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Relative import tool
#6
I've added support now for zip files in v3.0.6

Here's how the syntax works:

ParentFolder/
    ZippedFile.zip/
        ZippedPackage/                      <- and you want to import this zipped package
            __init__.py
        ZippedModule.py                     <- or this zipped module
    SubFolder1/
        SubFolder2/
            CurrentModule.py         <- you are here
from FooFinder.ZippedFile import ZippedPackage
from FooFinder.ZippedFile import ZippedModule
This uses zipimport.zipimporter.load_module to do the loading of ZippedModule or ZippedPackage, so it's limited to just what zipimporter can see. Searching the contents of the zip folder recursively would make it more complicated, and I couldn't think of a good use case for it.
Reply


Messages In This Thread
Relative import tool - by MadisonAster - Oct-13-2020, 12:16 AM
RE: Relative import tool - by Atekka - Oct-14-2020, 08:46 PM
RE: Relative import tool - by MadisonAster - Oct-15-2020, 05:51 PM
RE: Relative import tool - by Gribouillis - Oct-16-2020, 05:02 AM
RE: Relative import tool - by MadisonAster - Oct-16-2020, 08:07 PM
RE: Relative import tool - by MadisonAster - Oct-18-2020, 03:27 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020