File processing

Paul Winkler slinkp23 at yahoo.com
Tue Jul 10 15:05:26 EDT 2001


Chris McMillan wrote:
> 
> When I run my script, below, it complains after the line f = open(fname,
> 'r') saying that it expected string, list found.  I believe this happens
> because of what the glob command returns, but I'm not sure how to fix it.
> FYI - I'm running Python 2.0 on Windows NT.  Thanks in advance for your
> help!
> Chris

(snip)
> for fname in glob.glob('M:\\python\\*.dat'):
>    fname = glob.glob('M:\\python\\*.dat')

The first line assigns fname to each item from the list returned by glob.glob(),
one at a time until it runs out of filenames.

The second line then assigns fname to the list itself. Take this line out and
you should get what you want.

-- 
...................    paul winkler   ....................
custom calendars & printing: http://www.calendargalaxy.com
       A member of ARMS:   http://www.reacharms.com
            home page:  http://www.slinkp.com



More information about the Python-list mailing list