Re: string methods of a str subclass

2007-04-16 Thread Daniel Nogradi
> > Why is the strip( ) method returning something that is not a mystr > > instance? I would expect all methods operating on a string instance > > and returning another string instance to correctly operate on a mystr > > instance and return a mystr instance. > > Why would you expect that? > Would y

Re: string methods of a str subclass

2007-04-16 Thread 7stud
On Apr 16, 3:28 am, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote: > I would expect all methods operating on a string instance > and returning another string instance Ok, then this: class A(object): def __init__(self, s): self.s = s def strip(self): return self.s class mystr

Re: string methods of a str subclass

2007-04-16 Thread Duncan Booth
"Daniel Nogradi" <[EMAIL PROTECTED]> wrote: > Why is the strip( ) method returning something that is not a mystr > instance? I would expect all methods operating on a string instance > and returning another string instance to correctly operate on a mystr > instance and return a mystr instance. Wh

Re: string methods of a str subclass

2007-04-16 Thread 7stud
On Apr 16, 3:28 am, "Daniel Nogradi" <[EMAIL PROTECTED]> wrote: > I am probably misunderstanding some basic issue here but this > behaviour is not what I would expect: > > Python 2.4 (#1, Mar 22 2005, 21:42:42) > [GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2 > Type "help", "copyright", "

string methods of a str subclass

2007-04-16 Thread Daniel Nogradi
I am probably misunderstanding some basic issue here but this behaviour is not what I would expect: Python 2.4 (#1, Mar 22 2005, 21:42:42) [GCC 3.3.5 20050117 (prerelease) (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class mystr( str ): ...