Python – from . import

There is a PEP for everything. Quote from PEP8: Imports Explicit relative imports are an acceptable alternative to absolute imports, especially when dealing with complex package layouts where using absolute imports would be unnecessarily verbose: Guido’s decision in PEP328 Imports: Multi-Line and Absolute/Relative Copy Pasta from PEP328 Here’s a sample package layout: Assuming that the current file is either moduleX.py or subpackage1/__init__.py , … Read more

Relative imports for the billionth time

Script vs. Module Here’s an explanation. The short version is that there is a big difference between directly running a Python file, and importing that file from somewhere else. Just knowing what directory a file is in does not determine what package Python thinks it is in. That depends, additionally, on how you load the file into … Read more