a = b = 1 just syntactic sugar?

Michael Chermside mcherm at mcherm.com
Mon Jun 9 15:40:03 CEST 2003

Ed Avis writes:
  [... discussion of the statement/expression divide in Python ...]
> I don't know about perfect - 'print' seems rather an anomaly, and
> assignment to list and dictionary elements is beginning to look like a
> strange special case - but I agree that most of the time it works
> fairly well.

For what it's worth, I agree. sys.out.write() should be used instead
of the print statement... the only argument for having a separate
statement is convenience in writing tiny scripts. Of course, that's
a useful thing, but it in no way justifies wierd things like the
soft space, the addition of newlines based on a trailing comma, or
the ugly ">>".

And assignment to list and dictionary elements is, indeed, a wierd
case. It makes sense as a statement, but ALSO having a mutation
method makes sense. The fact that some mutable containers lack 
sensible mutation methods (eg, dict.set()) feels to me more like
an annoying oversight than a useful distinction.

> Lambda is the only real area where it starts to produce
> 'surprising' results, and that only because lambda is synactically
> restricted to contain only expressions.

But I like lambdas as they are, and it seems natural to me. Hmm... 
guess everyone comes along with slightly different expectations.

-- Michael Chermside

More information about the Python-list mailing list