Loop-and-a-half (Re: Curious assignment behaviour)

Greg Ewing greg at cosc.canterbury.ac.nz
Thu Oct 11 02:21:57 CEST 2001


Paul Rubin wrote:
> 
> I feel seriously cramped in Python when I have to say
> 
>   while 1:
>      x=get_next()
>      if not x: break
>      whatever(x)

I feel the solution to this is *not* to go in for
any sort of assignment-in-expressions hackery, but
to provide a decent loop-and-a-half control structure.
My current idea for this is

  while:
    x = get_next()
  gives x:
    whatever(x)

-- 
Greg Ewing, Computer Science Dept, University of Canterbury,	  
Christchurch, New Zealand
To get my email address, please visit my web page:	  
http://www.cosc.canterbury.ac.nz/~greg



More information about the Python-list mailing list