gmcm at hypernet.com
Mon Nov 29 14:05:01 CET 1999
Will Ware wrote:
> I find myself grumbling about having to type "x = x + 1". The
> really clean thing to do, given that integers are objects, would
> be to define increment and decrement methods, so you'd type
> something like "i.incr()". Then you'd want to go around looking
> for other objects for which it made sense to increment and
> decrement. Long ints and floats can do what integers do.
> Sequences (lists, tuples, strings, xranges) might grow and shrink
> in length. No good idea what to do for dictionaries. --
Now that you've had some coffee this morning, do you see
any problems with this, Will? I mean, assuming you don't
really want 0 == 1 to be sometimes true?
Seems to me that "++" would have to be an operator that, for
immutable operands, magically rebound the operand; while
calling an __incr__ method on mutable objects.
More information about the Python-list