Looping over a list question

mdsteele at gmail.com mdsteele at gmail.com
Tue Oct 3 21:05:41 CEST 2006


stephen at theboulets.net wrote:
> 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


Yes, there has:
http://groups.google.ca/group/comp.lang.python/browse_thread/thread/905313cf066c2d18/e6af21b68309415f




More information about the Python-list mailing list