(slightly OT): Python and linux - very cool

James J. Besemer jb at cascade-sys.com
Fri Aug 2 01:05:23 CEST 2002


Graham Ashton wrote:

> I say "generally not a good idea" above because some modules are actually
> designed to be used this way (e.g. gtk).

Like most things, there are exceptions to every rule.

E.g., the __all__ facility was designed to facilitate
importing * without extraneous clutter.

Some modules (with or without __all__ ) are
designed to only export a couple names and thus
import * is comparatively benign.

Seems if you're only referencing a few imported
names a few times in your module, there's no excuse
to not fully qualify the names.  If you're using many
of the imported names in a lot of places in your code,
then the module qualifier can sometimes hurt the clarity
of the code and you may be excused from using it.
IMHO.

E.g., I have encountered circumstances where I was
doing a LOT of string manipulation and I felt "from
string import *" was appropriate.

Nevertheless, generally I agree that you want to refer
to imported objects by their fully qualified names.

Regards

--jb

--
James J. Besemer  503-280-0838 voice
http://cascade-sys.com  503-280-0375 fax
mailto:jb at cascade-sys.com






More information about the Python-list mailing list