Curious assignment behaviour

Just van Rossum just at letterror.com
Wed Oct 10 09:47:11 CEST 2001


Paul Rubin wrote:

> Anyway, I can live with "while x:=get_next()" instead of x=get_next.
> But I feel seriously cramped in Python when I have to say
> 
>   while 1:
>      x=get_next()
>      if not x: break
>      whatever(x)
> 
> so I hope something is done about the issue.

I think this is the wrong example, as it can easily be written as a
for loop. Iterators in 2.2 will make that even more natural. Now if
you meant this:

  m = someRegex.match(...)
  if m:
      ...

vs.

  if m := someRegex.match(...):
      ...

you may have a point...

Just



More information about the Python-list mailing list