mutable ints: I think I have painted myself into a corner

Chris Angelico rosuav at gmail.com
Sat May 18 21:11:56 EDT 2013


On Sun, May 19, 2013 at 10:26 AM, Cameron Simpson <cs at zip.com.au> wrote:
> Before I toss this approach and retreat to my former "object"
> technique, does anyone see a way forward to modify an int subclass
> instance in place? (That doesn't break math, preferably; I don't
> do arithmetic with these things but they are, after all, ints...)
>

Why is it an int subclass? Because there are places where you want to
use it as though it were an int? It might be easier to render those,
instead, eg by creating a __int__ method. (Or is it "an __int__
method"? Not sure.)

ChrisA



More information about the Python-list mailing list