Am 25.10.2012 16:15 schrieb Grant Edwards:

I guess that depends on what sort of programs you write.  In my
experience, EXPR is usually a read from a file/socket/pipe that
returns '' on EOF. If VAR is not '', then you process, then you
process it inside the loop.

Right. The same as in

if regex.search(string) as match:
    process it

But with

def if_true(expr):
    if expr: yield expr

you can do

for match in if_true(regex.search(string)):
    process it

But the proposed if ... as ...: statment woulkd be more beautiful by far.

Thomas
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to