With a project structure like this:

├─main.py
└─src
    ├─dep1.py
    └─dep2.py

where the contents of each file is as follows:

main.py: import src.dep1 as firstdep; print("Total success")

dep1.py: import dep2 as seconddeb; print("success 1/3")

dep2.py: print("success 2/3")

Is the best way to do this creating an __init__.py file in src and importing src.dep2 in dep1.py? or is this a bad idea?

  • Limitless_screaming@kbin.earthOP
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    2 days ago

    Are you accusing me of not reading tfm? because I did, but was expecting this specific situation to be clarified on stackOverFlow, geeksForGeeks or somewhere similar. Since it seemed like this import pattern should be common.

    • rtxn@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      1 day ago

      I was pointing out a part of the documentation that you may have overlooked. In good faith, I might add, because the documentation is comprehensive but horribly signposted. Everything I wrote in my first comment is there, but in a less human, more technical phrasing.