I have tried to find a comprehensive guide whether using the import module
is best Or from module import
. I have just started with Python with the intention of developing web applications with Python and I am trying to start with the best practices in mind.
Actually, I was hoping that anyone could share their experiences, whether other developers have priorities and to avoid any gotchas under the road What's the best way
module import foo to import module
and The difference between is mainly subjective which you like best and keep it consistent in your use
Import module
import
statement
module.fu
in your code can be tedious and redundant (tedium to import modi P>
Module import
- Professionals:
- <
- Cons:
- Change your
import
To use a new item from the module to update the statement - You can
foo
. For example, it is less obvious that the comparison ofroof ()
tomath.ceil ()
For any suitable large set of code, if you can delete import *
in the module, then it can not be deleted. This is because it is difficult to determine which items are used in the code, which are coming from the 'module', which makes it easy to reach that point where you think you will be able to import
, but it is extremely difficult to ensure.
Comments
Post a Comment