if <assignment>:

Erik Max Francis max at alcyone.com
Sun Nov 24 16:52:12 EST 2002


André Næss wrote:

> if myvar = someFunction():
> 
> My question is, what is the rationale for this? Is it a technical
> issue? Or
> purely a matter of language design? I'm curious because I'm interested
> in
> the design og programming languages, not because I want this behavior
> changed in Pyton :)

It's a language design feature, intended to avoid the confusion between
when people write (say, in C):

	if (a = b) ...

but mean

	if (a == b) ...

Instead in Python assignments are treated as statements, not
expressions, so they cannot appear in an if clause.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Money talks / But love is for real / And you know that
\__/ Neneh Cherry
    Erik Max Francis' bookmarks / http://www.alcyone.com/max/links/
 A highly categorized list of Web links.



More information about the Python-list mailing list