realization: no assignments inside expressions
Simon Burton
simon at arrowtheory.com
Thu May 18 19:48:05 EDT 2006
I've been doing a little c programming again (ouch!) and it's just hit
me
why python does not allow assignment inside expressions (as in c):
because it is absolutely essential that all assignments are as visible
as possible. In python the assignment is the declaration; when
declarations
are as cheap as this it's hard not to fall to the temptation to re-use
a
variable unknowingly. I am constantly scanning the line of assignments
to see what variables are already live, and I just realised how easy it
is
to do that. Up to now I guess I thought it was just a restriction to
stop new
users of python from writing too obfuscated code.
wow.
Simon.
More information about the Python-list
mailing list