[Tutor] Confused "from module import Name" better than "importmodule"?

Alan G alan.gauld at freenet.co.uk
Mon Jul 11 22:11:24 CEST 2005

> I guess it could be easier to replace the implementation, 
> for example if you split a module you could change
> from module import Name1, Name1
> to
> from module1 import Name1
> from module2 import Name2
> and the rest of the client code wouldn't have to change.

Thats true, but OTOH it's nmuch easier to accidentally create 
another variable with the same name as an imported one:

from module1 import Name1

# and much more

Name1 = 42   # oops I've just lost my module1.Name1 !!1

That's why I don't like it. Just look at the number of modules 
with an open() function, a careless import statement could radically 
change behaviour but explicit module.function behaviour is reliably 

Alan G.

More information about the Tutor mailing list