[Python-ideas] A conditional "for" statement

Ben Finney ben+python at benfinney.id.au
Fri Apr 24 02:24:58 CEST 2009

"Michael S. Gilbert"
<michael.s.gilbert at gmail.com> writes:

> The purpose would also be efficiency. It's less efficient to check the
> condition m==2 during every loop iteration than it is to set up a list
> that excludes m=2 to begin with.

Huh? “Set up the list” involves exactly the conditional check for each
item in the original sequence. So those condition checks for each item
in the original sequence are going to be paid anyway.

 \       “bash awk grep perl sed, df du, du-du du-du, vi troff su fsck |
  `\                     rm * halt LART LART LART!” —The Swedish BOFH, |
_o__)                                            alt.sysadmin.recovery |
Ben Finney

More information about the Python-ideas mailing list