Label-Value (was: Re: Inheriting the @ sign from Ruby)

Alex Martelli aleaxit at yahoo.com
Fri Dec 15 08:13:20 EST 2000


"Rainer Deyke" <root at rainerdeyke.com> wrote in message
news:rWd_5.26820$x6.14119694 at news2.rdc2.tx.home.com...
    [snip]
> > > class MutableInt(UserInt.UserInt):
> > >   def set(self, value):
> > >     self.data = value
> >
> > UserInt is not in the Python 2 docs, though it's nice to hear it
> exists:-).
>
> Actually it doesn't, but it's trivial (if tedious) to implement.

But, if UserInt is not a funky metaclass, how will MutableInt live
up to its name?  Surely it should at least redefine all of the
in-place methods...:

    x = y = MutableInt(23)
    x += 1

I would expect y's value-as-integer to be 24 now.  So MutableInt
should implement __iadd__ (which the Python 2 docs only mention
in passing in one place, while talking of sequence and mapping
types, but that one _is_ a doc booboo, right?).


Alex






More information about the Python-list mailing list