Walk thru each subdirectory from a top directory
Diez B. Roggisch
deets at nospam.web.de
Mon Feb 26 16:46:43 EST 2007
More information about the Python-list mailing list
Mon Feb 26 16:46:43 EST 2007
- Previous message (by thread): is it possible to use ironpython 1.1 in visual studio 2005
- Next message (by thread): Walk thru each subdirectory from a top directory
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
silverburgh.meryl at gmail.com schrieb: > i am trying to use python to walk thru each subdirectory from a top > directory. Here is my script: > > savedPagesDirectory = "/home/meryl/saved_pages/data" > > dir=open(savedPagesDirectory, 'r') > > for file in dir: > if (isdir(file)): > # get the full path of the file > fileName = savedPagesDirectory + file + 'index.html' > print fileName > > $ ./scripts/regressionTest.py > Traceback (most recent call last): > File "./scripts/regressionTest.py", line 12, in ? > dir=open(savedPagesDirectory, 'r') > IOError: [Errno 21] Is a directory > > But I get the above error: > > Can you please tell me what did I do wrong? You can't open a directory. Use the function os.walk to do what you want. Diez
- Previous message (by thread): is it possible to use ironpython 1.1 in visual studio 2005
- Next message (by thread): Walk thru each subdirectory from a top directory
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list