[Tutor] Confused "from module import Name" better than "importmodule"?
alan.gauld at freenet.co.uk
Mon Jul 11 22:06:52 CEST 2005
> I'm confused. I was just reading the URL below..
Me too. :-)
> and this statement confused me: "Always use from module import Name,
> Name2, Name3.. syntax instead of import module or from module import
> *. This is more efficient, reduces typing in the rest of the code,
> and it makes it much easier to see name collisions and to replace
The efficiency gain is negligible.
The typing can be better reduced by using
import modulename as m
And it definitley doesn't make it easier to see name collisions, they
just silently collide and one or the other name will be hidden with
> To me, import module is more explicit.
> It seems to easier to read CoolModule.niceFunction() than just
Easier to read but slightly harder to type. Personally I can live with
More information about the Tutor