On 13 Dec 2006 07:47:23 -0800, Paul Rubin <"http://phr.cx"@nospam.invalid> wrote: > at <[EMAIL PROTECTED]> writes: > > I have a lot times the following code: > > > > for x in [-2, -1, 0, 1, 2, 3, 4]: > > if x > 0: > > ... more code... > > Use: > > for x in (x in [-2, -1, 0, 1, 2, 3, 4] if x > 0): > ... more code ... > --
or filter: from itertools import ifilter for x in ifilter(lambda x: x > 0, [-2, -1, 0, 1, 2, 3, 4]): ...more code... > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list