a = b = 1 just syntactic sugar?

Martin v. Löwis martin at v.loewis.de
Tue Jun 3 14:35:54 EDT 2003


Kendear <kendear at nospam.com> writes:

> > 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:
> > 	...
> 
> so you mean in Python,  =  is just
> like if, for, while... ?

Yes, in the sense that assignment is a statement, not an expression.
No, in the sense that if, for, while require a block, whereas
assignment doesn't.

So = is more like print, import, raise...

Regards,
Martin





More information about the Python-list mailing list