Is it Pythonic to import an external symbol imported into another module?

117 Views Asked by At

Please guide me on the pythonic way for a minor code-standards question. Searching SO re imports gets me many discussions comparing import foo vs from foo import bar which is not my concern here. Still I apologize if I am creating a dupe Q.

My team sometimes puts up code for review with import statements like below and I'm struggling to give advice:

Module our_a.py has a classic import statement, this is fine:

from famous_package import some_function
# .. call the famous package's some_function()

Module our_b.py imports the same symbol, but from our_a not from famous_package:

from our_a import some_function
# .. call the famous package's some_function()

Is there a name for this practice? Indirect import? Re-import?? Anyhow it works fine, and flake8 does not complain about import statements in module our_b. Is there any benefit here? My instinct says, our_b should just import some_function from famous_package directly. Thanks in adv for your insights.

0

There are 0 best solutions below