Why return None?
Paul Rubin
http
Fri Aug 27 04:38:06 EDT 2004
Antoon Pardon <apardon at forel.vub.ac.be> writes:
> but having operators like '+=' which have a different kind of result
> depending on whether you have a mutable or immutable object is IMO
> not such a good design and I wonder what design principle inspired them.
+= was added to Python fairly recently (in 2.0, I think) and there was
a lot of agonizing about whether to add it. It was one of those
things like the ?: construction. On the one hand there was the
abstract objection you raise. On the other hand there were lots of
users frustrated at being unable to say v[f(x)] += 1 instead of having
to call f twice or introduce a temp variable or something.
Eventually, practicality beat purity.
More information about the Python-list
mailing list