module not callable - why not?
Peter Hansen
peter at engcorp.com
Fri Apr 9 14:41:25 EDT 2004
Peter Hansen wrote:
> Generally speaking it's safe to do (and so is "from xxx import *")
> but considered poor form, extremely so in the latter case. And
> it's not an arbitrary thing: doing this makes code less readable
> and maintainable because it becomes unclear where names are
> coming from without constant reference to the list of imports
> at the top.
I think for the simple "from xxx import yyy" I've overstated
the case somewhat, especially given that this is something I
do a lot too.
Rather than calling it "poor form", I would say merely that
overuse of it can lead to code becoming less clear. For the
usual cases, including John Roth's example with "as q", it's
not poor form if used relatively sparingly, and can actually
increase readability in those cases.
-Peter
More information about the Python-list
mailing list