class X (object):
pass
X() += 2
> SyntaxError: can't assign to function call
Suppose I actually had defined __iadd__ for class X. Python says this
syntax is invalid. I wish is wasn't.
Here's where I might use it. Suppose I have a container class. Suppose I
could make a slice of this container, like so:
c = Container()
s = Slice (c, 0, 10)
where "Slice" is a class. Then:
s += 2
Would perform iadd on the slice of the container. A convenient syntax would
be:
Slice (c, 0, 10) += 2
Does anyone else think this would be a good addition to Python?
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com