0

Let's assume I do have such package structure:

foobar/
    - foo/bar.py
    - ...
    main.py

Shall I use:

from foo import bar 

or

import foo.bar

or

import foo.bar as bar

Currently, I do from foo import bar as I find it correct but I want to double check it (I think Python documentation recommends this also).

naivepredictor
  • 898
  • 4
  • 14
  • 1
    Possible duplicate of [Python: importing a sub‑package or sub‑module](https://stackoverflow.com/questions/12229580/python-importing-a-sub-package-or-sub-module) – Nihal Mar 07 '19 at 12:39
  • Yes, correct as it is possible duplicate but I do not find one line answer in that question. Probably 'from subpackage import module' is the answer but I wonder what ppl think about 'import subpackage.module' if it is wrong or not. – naivepredictor Mar 07 '19 at 12:45

0 Answers0