while loop with the condition used in the body

Ulrich Eckhardt eckhardt at satorlaser.com
Wed Feb 24 04:15:17 EST 2010


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 that?

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list