Tim Chase <python.l...@tim.thechases.com> wrote: > If you're doing more processing than just printing it, your > for-loop is a better (clearer) way to go. If you have lots of > processing code, it might help to do the inverse: > > for filename in os.listdir(location): > if not filename.startswith('_'): continue > lots() > of_processing() > and_your_complex_logic() > goes() > here()
Personally, I'd still go with a generator to drive the for-loop: underscored_files = (f for f in os.listdir(<location>) if not f.startswith('_')) for filename in underscored_files: etc... What I'm traversing in the for-loop is far more obvious (to me) from the name of the generator than from having to parse the first few lines of the loop. It's a lot easier to genericise that behaviour too. -- http://mail.python.org/mailman/listinfo/python-list