On Thu, Aug 28, 2008 at 6:20 AM, GHZ <[EMAIL PROTECTED]> wrote: > is there a shortcut I'm missing?
Well, there's another way to do it, using the filter built in function: for filename in filter(lambda f:f.endswith('.xml'), os.listdir('.')): print filename You can do the same thing with itertools.ifilter if you need to deal with arbitrary iterables. I think your first example of: for filename in os.listdir('.'): if filename.endswith('.xml'): <do something> Is the most readable though. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list