TypeError: 'module' object is not callable (newby question)

Charles Russell SPAMworFREEwor at bellsouth.net
Mon Aug 14 17:09:16 EDT 2006


John Machin wrote:

> 
> Contemplate the following:
> 
> C:\junk>type glob.py
> if __name__ == "__main__":
>     print "*** Being run as a script ..."
>     import glob
>     print "glob was imported from", glob.__file__
>     print "glob.glob is", type(glob.glob)
>     print "glob.glob was imported from", glob.glob.__file__
>     print "(glob.glob is glob) is", glob.glob is glob
>     print "--- end of script"
> else:
>     print "*** Aarrgghh!! I'm being imported as", __name__
>     import glob
>     print "glob was imported from", glob.__file__
>     print "glob.glob is", type(glob.glob)
>     print "glob.glob was imported from", glob.glob.__file__
>     print "(glob.glob is glob) is", glob.glob is glob
>     print "--- end of import"
> 

Thanks.  Another newby question:  __name__ and __file__ appear to be 
predefined variables.  To look up their meaning in the manual, is there 
some method less clumsy than grepping the whole collection of .html 
source files?  I can't find any comprehensive index.



More information about the Python-list mailing list