a = b = 1 just syntactic sugar?

Brian Quinlan brian at sweetapp.com
Tue Jun 3 10:56:02 CEST 2003


> I don't like the fact that you can say in
> Python
> 
>      a = b = 1
> 
> but you can't say
> 
>      a = (b = 1)
> 
> which is perfectly fine in C or Perl.

In C and Perl, assignment is an expression. In Python it is a statement.
This is a deliberate design decision to prevent people from writing code
like this:

while a = 5:
	...

Cheers,
Brian






More information about the Python-list mailing list