TypeError: 'module' object is not callable (newby question)
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Mon Aug 14 14:35:18 EDT 2006
In <yp2Eg.1858$VQ.825 at trndny05>, Charles Russell wrote:
> Why does this work from the python prompt, but fail from a script?
> How does one make it work from a script?
>
> #! /usr/bin/python
> import glob
> # following line works from python prompt; why not in script?
> files=glob.glob('*.py')
> print files
>
> Traceback (most recent call last):
> File "./glob.py", line 2, in ?
> import glob
> File "/home/cdr/python/glob.py", line 5, in ?
> files=glob.glob('*.py')
> TypeError: 'module' object is not callable
Don't call your file `glob.py` because then you import this module and not
the `glob` module from the standard library.
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list