News for hackers. Stuff that matters.
Re:Never run ‘python’ in your downloads folder by lmuench on Sunday August 23, 2020 @09:53PM (#24256904)
Python’s import system is weird but it does make sense when you use absolute imports:

  project
  ├── main.py
  ├── package1
  │   ├── module1.py
  │   └── module2.py
  └── package2
      ├── __init__.py
      ├── module3.py
      ├── module4.py
      └── subpackage1
          └── module5.py
As long as the file containing the main() function resides in the top-level folder you can use absolute imports in every file, e.g.

  from package1 import module1
  from package1.module2 import function1
  from package2.subpackage1.module5 import function2

There are no comments on this comment yet.