No "side effect" assignment!

Martin Maney maney at
Thu Sep 18 07:23:45 CEST 2003

Sean Ross <sross at> wrote:
> If you must use assignments in expressions, you might find the following
> recipes useful:

Did I forget about this one or is it in fact new?  It is, as the author
says, an ugly hack at the implementation level, but that seems to be
its only drawback.  It doesn't use any hidden state that could be
altered unexpectedly, and is only a minor eyesore; those who worry
about accidentally writing an assignment in place of an equality test
will consider that last to be a feature, of course.  Perhaps it could
be improved, slightly, by being renamed to "let"?  <evil grin>


The hope of obliterating this recipie is IMO the strongest argument in
favor of adding operator= to Python.  I can think of no reason to
prefer this to 202234 aside from the chance that the language
implementation detail used in the latter's implementation could
conceivably go away someday.

Short form: 66061 Considered Harmful.  What, you thought it was just a
coincidence it had all those sixes in its number?

People make secure systems insecure because
insecure systems do what people want and
secure systems don't.  -- James Grimmelmann

More information about the Python-list mailing list