Does Python import order matter

Issue

I read here about sorting your import statements in Python, but what if the thing you are importing needs dependencies that have not been imported yet? Is this the difference between compiled languages and interpreted? I come from a JavaScript background and the order in which you load your scripts matter, whereas Python appears not to care. Thanks.

Solution

No, it doesn’t, because each python module should be self-contained and import everything it needs. This holds true for importing whole modules and only specific parts of it.

Answered By – Tymoteusz Paul

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published