If - Or statements
Steven Bethard
steven.bethard at gmail.com
Mon Jun 6 10:57:27 EDT 2005
bruno modulix wrote:
> Here's a somewhat more pythonic version:
>
> filelist = os.listdir(path)
> for filename in filelist:
> # I assume you want to remember what's the ext is
> ext = os.path.splitext(filename)
Check the docs[1]. This should probably read:
_, ext = os.path.splitext(filename)
because splitext returns a pair of (root, ext).
> # debug trace
> print "filename : %s - ext : %s" % (filename, ext)
> if ext in ['.this', '.that', '.whatnot']:
> print "ext is %s - should process this file" % ext
STeVe
[1] http://docs.python.org/lib/module-os.path.html
More information about the Python-list
mailing list