[Python-ideas] if in for-loop statement

Régis Martin rmartin at astek.fr
Thu Feb 23 13:11:36 EST 2017


Hello,
why not using the filter function?

for x in filter(is_prime, range(100)):
     # do something with x

This is equivalent as was mentionned at first:

     for x in range(100) if is_prime(x):
         # do things with x

Régis

-- 
Régis  Martin
Directeur de Projets Astek Industrie
Tel: 06-83-53-15-05
http://www.groupeastek.com/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rmartin.vcf
Type: text/x-vcard
Size: 182 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170223/8a123a87/attachment.vcf>


More information about the Python-ideas mailing list