문제

If my foo.py is merely foo_var = 1 and bar.py is merely import foo, I know I can write baz.py that says from bar import foo_var, but should I? (Or should I instead do from foo import foo_var?)

Is there any reason why chaining imports like this would be bad?

도움이 되었습니까?

해결책

No, it's fine. The first (from bar ...) compiles and runs both foo.py and bar.py while the latter (from foo ...) only compiles and runs foo.py, but if bar.py only contains import foo, the overhead is negligible.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top