changing value of 'self' when subclassing int
Alex Martelli
aleaxit at yahoo.com
Mon Feb 20 12:34:33 EST 2006
David Coffin <dcoffin at gmail.com> wrote:
> I'd like to subclass int to support list access, treating the integer
> as if it were a list of bits.
Fine, but:
> Assigning bits to particular indices involves changing the value of
> the integer itself, but changing 'self' obviously just alters the
...integers are immutable, like all other numbers in Python: there is NO
way to "change the value of the integer itself".
I originally proposed to have "mutable numbers" (at least optionally) in
gmpy, but the reaction was a broadside against the idea, to the point
that I never got around to it -- gmpy includes a lot of functionality
for bit-level manipulation, but still only with immutable bitlists
(mapped into gmpy.mpz instances).
Alex
More information about the Python-list
mailing list