[Tutor] Imports (Py 3)

Mats Wichmann mats at wichmann.us
Mon Jan 13 09:49:24 EST 2020


On 1/13/20 6:33 AM, S D wrote:
> I have a folder `abc_app`, which contains a module `utils`. In the
> `abc_app` folder, I also have a subfolder `tests` which contains a module
> `test_api`
> 
> How do I import a function from the `utils` module from the `test_api`
> module?

"relative imports".  which can be vaguely confusing, it's worth reading 
a tutorial on them to be sure you understand.

if "foo" is in "utils", what you described ought to look like:

from ..utils import foo

(unless I managed to confuse myself!)




More information about the Tutor mailing list