> > 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 you expect the __str__ and__repr__ methods also to return a mystr > instance? If not those, then which other ones might also be excluded? > Is x.encode('zip') still a mystr instance or an encoded byte-string?
Okay, good point, thanks. > > How would I achieve something > > like this without manually copying all string returning methods from > > str and stuffing the result to mystr( ) before returning? > > You don't without wrapping all the affected methods. It doesn't need to > involve manual copying though: you have a programming language available so > just write a list of method names and then some code to wrap them > automatically. Yes, this is in fact what I am doing, using __getattr__ and such. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list