Quantcast
Channel: Python import mechanics - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Python import mechanics

$
0
0

I have two related Python 'import' questions. They are easily testable, but I want answers that are language-defined and not implementation-specific, and I'm also interested in style/convention, so I'm asking here instead.

1)

If module A imports module B, and module B imports module C, can code in module A reference module C without an explicit import? If so, am I correct in assuming this is bad practice?

2)

If I import module A.B.C, does that import modules A and A.B as well? If so, is it by convention better to explicitly import A; import A.B; import A.B.C?


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images