I am finding myself often doing for loops over a subset of a list, like:<br><br> for r in results:<br> if r.numNodes != numNodes:<br> continue<br> # do something with r<br clear="all">
<br>It would be nice if the plain for loop was as flexible as list comprehensions and allowed an optional if clause, like this:<br><br> for r in results if r.numNodes == numNodes:<br> # do something with r
<br clear="all"><br>Has this idea come up before? Does anyone else like this idea?<br><br>-- <br>Gustavo J. A. M. Carneiro<br>INESC Porto, Telecommunications and Multimedia Unit<br>"The universe is always one step beyond logic." -- Frank Herbert