Dealing with files...

George Kinney gk_2345 at yahoo.com
Sat Apr 26 10:46:46 EDT 2003


"lost" <lost at soul.net> wrote in message
news:pan.2003.04.26.14.19.35.262492 at soul.net...
> thanks for the info, however that doesn't seem to work either? here's the
> whole program that I'm trying:
> #!/usr/bin/python
> from glob import glob
> file_list = glob.glob('/var/www/html/') for each_file in file_list:
>         print each_file
> print "done"
>
> Running that gives me:
> Traceback (most recent call last):
>   File "files.py", line 6, in ?
>     file_list = glob.glob('/var/www/html/')
> AttributeError: 'function' object has no attribute 'glob'
>
> Any ideas where I'm going wrong?

Sorry, I should have pointed out that glob does wild-card expansion (not
just a dir list).
So if you tried :
file_list = glob.glob('/var/www/html/*')   # (notice the *, could also be
*.html or whatever)
 for each_file in file_list :
     print each_file
print "done"

It'll behave like you expect.








More information about the Python-list mailing list