Re: Setting "value" of an int-derived class

2006-09-02 Thread Sam Pointon
Ken Schutte wrote: > So, that's good. But, how can I change the value of x from 5 to > something else, without creating a new instance? > > I suppose I could create a function that creates a new "foo" and copies > its attributes, but is there a more direct way? Is the value "5" stored > in some s

Re: Setting "value" of an int-derived class

2006-09-02 Thread Diez B. Roggisch
Ken Schutte schrieb: > Lets say I want an integer class that lets you attach arbitrary > attributes. I can simply do: > > class foo(int): pass > > x = foo(5) > x.text = "okay" > print x, x.text # prints "5 okay" > > So, that's good. But, how can I change the value of x from 5 to > somethin

Setting "value" of an int-derived class

2006-09-02 Thread Ken Schutte
Lets say I want an integer class that lets you attach arbitrary attributes. I can simply do: class foo(int): pass x = foo(5) x.text = "okay" print x, x.text # prints "5 okay" So, that's good. But, how can I change the value of x from 5 to something else, without creating a new instance? I