deriving from str

Terry Reedy tjreedy at udel.edu
Tue Dec 28 07:26:19 CET 2004


"dataangel" <k04jg02 at kzoo.edu> wrote in message 
news:41D015C9.3050005 at kzoo.edu...
> Paolo Veronelli wrote:
>
>> I want to add some methods to str class ,but when I change the __init__ 
>> methods I break into problems

Immutable types cannot be changed in __init__.  They are initialized in 
__new__, which is normally invisible.  So you have to overide that if you 
wish to affect the value.  Google previous posts for its calling sequence. 
int, str, tuple, etc do not have __init__ methods since there is nothing 
more to once instances are initialized.

Terry J. Reedy






More information about the Python-list mailing list