How to do relative imports in Python?

前端 未结 15 3362
情深已故
情深已故 2020-11-21 04:47

Imagine this directory structure:

app/
   __init__.py
   sub1/
      __init__.py
      mod1.py
   sub2/
      __init__.py
      mod2.py

I\'

15条回答
  •  天命终不由人
    2020-11-21 05:28

    "Guido views running scripts within a package as an anti-pattern" (rejected PEP-3122)

    I have spent so much time trying to find a solution, reading related posts here on Stack Overflow and saying to myself "there must be a better way!". Looks like there is not.

提交回复
热议问题