changing value of 'self' when subclassing int
Fuzzyman
fuzzyman at gmail.com
Tue Feb 21 05:58:00 EST 2006
David Coffin wrote:
> I'd like to subclass int to support list access, treating the integer
> as if it were a list of bits.
> Assigning bits to particular indices involves changing the value of
> the integer itself, but changing 'self' obviously just alters the
> value of that local variable.
> Is there some way for me to change the value of the BitSequence
> object itself? I've also tried wrapping and delegating using
> __getattr__, but I couldn't figure out how to handle in-place methods.
>
Probably your best bet is to have the assignment done as a method call
which returns the new value.
All the best,
Fuzzyman
http://www.voidspace.org.uk/python/index.shtml
> Thanks for your help,
> David Coffin
>
>
More information about the Python-list
mailing list