Re: while loop with the condition used in the body

2010-02-24 Thread Gregory Ewing
Ulrich Eckhardt wrote: so why not: while as : ... and also: if as : ... This sort of thing has been suggested repeatedly in the past, and it's always been rejected. That's not likely to change. Look up the past threads for the reasons why. -- Greg -- http://mail.python.or

Re: while loop with the condition used in the body

2010-02-24 Thread Ulrich Eckhardt
Peter Otten wrote: > Duncan Booth wrote: >> for rq in incoming_requests(...): >>handle_request(rq) > > ...and a likely implementation would be > > def incoming_requests(...): > while True: > rq = ... # inlined version of get_request() > if not rq: > break >

Re: while loop with the condition used in the body

2010-02-24 Thread Peter Otten
Duncan Booth wrote: > Peter Otten <__pete...@web.de> wrote: > >> Ulrich Eckhardt wrote: >> >>> I'm looking for a way to write code similar to this C code: >>> >>> while(rq = get_request(..)) { >>> handle_request(rq); >>> } >>> >> Assuming get_request(...) is called with the same argum

Re: while loop with the condition used in the body

2010-02-24 Thread Duncan Booth
Peter Otten <__pete...@web.de> wrote: > Ulrich Eckhardt wrote: > >> I'm looking for a way to write code similar to this C code: >> >> while(rq = get_request(..)) { >> handle_request(rq); >> } >> > Assuming get_request(...) is called with the same arguments on each > iteration and uses

Re: while loop with the condition used in the body

2010-02-24 Thread Peter Otten
Ulrich Eckhardt wrote: > I'm looking for a way to write code similar to this C code: > > while(rq = get_request(..)) { > handle_request(rq); > } > > Currently I'm doing > > while True: > rq = get_request(...) > if not rq: > break > handle_request(rq) > >

Re: while loop with the condition used in the body

2010-02-24 Thread Arnaud Delobelle
Ulrich Eckhardt wrote: > Hi! > > I'm looking for a way to write code similar to this C code: > > while(rq = get_request(..)) { > handle_request(rq); > } > > Currently I'm doing > > while True: > rq = get_request(...) > if not rq: > break > handle_request(rq)

while loop with the condition used in the body

2010-02-24 Thread Ulrich Eckhardt
Hi! I'm looking for a way to write code similar to this C code: while(rq = get_request(..)) { handle_request(rq); } Currently I'm doing while True: rq = get_request(...) if not rq: break handle_request(rq) in Python 2.6. Any suggestions how to rewrite tha