SV: Don't understand error message

Lars Lundstedt lars.lundstedt at telia.com
Wed Apr 26 00:30:35 EDT 2000


Ahhhh...that did the trick!

Thanks!

Alex <cut_me_out at hotmail.com> skrev i
diskussionsgruppsmeddelandet:etd1z3uf5ua.fsf at w20-575-109.mit.edu...
>
> > 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?
>
> Yeah, the problem is, your file is called glob.py, and that is loaded
> when you import glob.  Instead, you should be loading the glob from the
> standard python library.  To get around this, one thing you could do is
> rename your glob.py file to my_glob.py, and remove your old glob.py and
> glob.pyc.  Then 'python my_glob.py *.py' should work fine.  At least,
> that solved the problem for me.
>
> Alex.





More information about the Python-list mailing list