Looping over a list question

stephen at theboulets.net stephen at theboulets.net
Tue Oct 3 13:50:04 EDT 2006


I found myself writing:

for f in [i for i in datafiles if '.txt' in i]:
    print 'Processing datafile %s' % f

but I was wishing that I could have instead written:

for f in in datafiles if '.txt' in f:
    print 'Processing datafile %s' % f

Has there ever been a proposal for this? Just wondering ...

Stephen Boulet




More information about the Python-list mailing list