other python ideas
D'Arcy J.M. Cain
darcy at vex.net
Thu May 25 09:30:52 EDT 2000
Jeff Massung <jmassung at magpiesystems.com> wrote:
> Arnold de Vos wrote in message
>>Yep. As pointed out on this group from time to time, import from * can be
>>harmful.
> I'm new to Python - I'm understand why it is harmful (finally ;) - but was
> wondering, if it is that harmful, why have it to being with (what good can
> come from using it)?
I find it useful in module writing. I will often have a module that imports
other modules, either my own or system ones, and I want to avoid the
extra layers of reference. For example, let's say I was writing a module
and I wanted the stat constants to be available through it. I don't
want to have to name each constant (what if a new one gets added later?)
and I dont' want the user of the module to have to do something like
mymodule.stat.S_ISDIR so I import * from stat after checking carefully
that it doesn't clash with my own module. Now the above is mymodule.S_ISDIR.
The user is still safe but he doesn't have to know what I imported.
--
D'Arcy J.M. Cain <darcy at vex.net> | Democracy is three wolves
http://www.vex.net/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
More information about the Python-list
mailing list