On Sun, Jul 13, 2008 at 12:55 PM, mk <mrkafk@gmail.c omwrote:
Through the str.__new__ method: http://docs.python.org/ref/customization.html
Calling a constructor:
foo = Foo(1, 2, 3)
Is roughly equivalent to:
foo = Foo.__new__(Foo , 1, 2, 3)
Foo.__init__(fo o, 1, 2, 3)
As a side note, you may already know this, but it's not necessary to
create a property setter that raises an error to make a property
read-only; you can simply not define a setter method.
-Miles
So my updated question is where does this lstr() instance keep the original
value ('abcdef')? It obviously has smth to do with inheriting after str
class, but I don't get the details of the mechanism.
value ('abcdef')? It obviously has smth to do with inheriting after str
class, but I don't get the details of the mechanism.
Calling a constructor:
foo = Foo(1, 2, 3)
Is roughly equivalent to:
foo = Foo.__new__(Foo , 1, 2, 3)
Foo.__init__(fo o, 1, 2, 3)
As a side note, you may already know this, but it's not necessary to
create a property setter that raises an error to make a property
read-only; you can simply not define a setter method.
-Miles