[Tutor] Confused "from module import Name" better than "import module"?
Matt Richardson
marichar at csusb.edu
Mon Jul 11 19:19:13 CEST 2005
Kent Johnson wrote:
<heavily snipped>
> from module import * is problematic and discouraged. It causes namespace pollution and makes it harder to find out where a name is defined.
>
> Other than that I think it is personal preference.
>
I have avoided the 'from module import *' style for the reasons you
mentioned, but I have a question about 'import module' versus 'from
module import name': is there a performance hit to consider when
importing the entire module rather than just getting the specific
niceFunction()? Right now,it's more of a curiousity as my programs are
fairly small and don't do a whole lot. I would imagine that there would
be a penalty, but for now I'm happy with keeping my namespaces distinct
and knowing what came from where at a glance.
Matt
--
Matt Richardson
IT Consultant
College Of Arts & Letters
CSU San Bernardino
(909)537-7596
More information about the Tutor
mailing list