Don't understand error message

Quinn Dunkan quinn at lira.ugcs.caltech.edu
Tue Apr 25 13:40:59 EDT 2000


On Tue, 25 Apr 2000 17:21:21 GMT, Lars Lundstedt <lars.lundstedt at telia.com>
wrote:
>I'm halfway through "Learning Python" and I'm stuck on the example on page
>255.
>
>It goes like this:
>
>import sys, glob, operator
>print sys.argv[1:]
>sys.argv = reduce(operator.add, map(glob.glob, sys.argv))
>print sys.argv[1:]
>
>When called with "python glob.py *.py" on Win98 I'm supposed to get a list
>of all .py files in the current directory but instead I get:
>
>Traceback (innermost last):
>  File "glob.py", line 1, in ?
>    import sys, glob, operator
>  File "glob.py", line 3, in ?
>    list = reduce(operator.add, map(glob.glob, '*.py'))
>TypeError: call of non-function (type module)
>
>Anyone know why?

Eh, this is a cute one.  You named your module glob.py, so when you import
glob, it imports itself, not the glob.py from the stdlib.  So glob.glob *is* a
module: itself (so is glob.glob.glob.glob.glob.glob...).  Try renaming your
module :)



More information about the Python-list mailing list