[Python-Dev] [1.6]: UserList, Dict: Do we need a UserString class?

Peter Funk pf@artcom-gmbh.de
Wed, 29 Mar 2000 08:30:22 +0200 (MEST)


Hi!

> On Wed, 29 Mar 2000, Peter Funk wrote:
> 
> > class UserString:
> >     def __init__(self, string=""):
> >         self.data = string
>           ^^^^^^^
Moshe Zadka wrote:
> Why do you feel there is a need to default? Strings are immutable

I had something like this in my mind:

class MutableString(UserString):
    """Python strings are immutable objects.  But of course this can
    be changed in a derived class implementing the missing methods.

        >>> s = MutableString()
	>>> s[0:5] = "HUH?"
    """
    def __setitem__(self, char):
        ....
    def __setslice__(self, i, j, substring):
        ....
> What about __int__, __long__, __float__, __str__, __hash__?
> And what about __getitem__ and __contains__?
> And __complex__?

I was obviously too tired and too eager to get this out!  
Thanks for reviewing and responding so quickly.  I will add them.

Regards, Peter
-- 
Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260
office: +49 421 20419-0 (ArtCom GmbH, Grazer Str.8, D-28359 Bremen)