python-dev

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [Python-Dev] In-place operators Antoine Pitrou Tue Mar 17 16:00:51 2009

Raymond Hettinger <python <at> rcn.com> writes:
> 
> I'm sure that consistency/completeness/safe_vs_sorry 
> was the reason they were added.  But, if they aren't useful, 
> they never should have been (IMO).  It wastes the time of 
> people who try to use them and then find-out that they don't 
> act as expected (the assignment doesn't take place)

>>> l = []
>>> operator.iadd(l, [5])
[5]
>>> l
[5]

The operation /does/ occur in-place for mutable types. Yes, the semantics are
non-obvious for non-mutable types, but that doesn't make it completely useless.


_______________________________________________
Python-Dev mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/alexiscircle%40gmail.com