output from external commands
Peter Hansen
peter at engcorp.com
Mon Oct 24 12:24:18 EDT 2005
Mike Meyer wrote:
> darren kirby <bulliver at badcomputer.org> writes:
>
>>If all you want is filenames this will work:
>>
>>>>>import glob
>>>>>files = ["%s" % f for f in glob.glob("*")]
>
>
> What's the point of doing "%s" % f? How is this different from just
> file = [f for f in glob.glob("*")]?
Answering narrowly, the difference is that using "%s" calls str() on the
items in the result list, while your suggestion does not. ("Why not
just use str(f) instead of the less clear '%s' % f?" would be a valid
question too though.)
-Peter
More information about the Python-list
mailing list