On Fri, 01 Jan 2010 13:48:28 +1100, Ben Finney wrote: > "W. eWatson" <wolftra...@invalid.com> writes: > >> Steven D'Aprano wrote: >> > NameError: name 'mod' is not defined > >> So where is it? Here are the choices. import sys, os, glob >> import string >> from numpy import * > > If you use ‘from foo import *’ you forfeit any way of saying where a > name in your code gets bound.
Not quite: >>> from math import * >>> sin.__module__ 'math' But this only works with functions and classes, not arbitrary objects: >>> pi.__module__ Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'float' object has no attribute '__module__' > Hence, don't do that. Avoiding "from module import *" is generally excellent advice. There's one or two exceptions, but if you have to ask what they are, you don't need to know *wink* -- Steven -- http://mail.python.org/mailman/listinfo/python-list