subclassing Python types

zzbbaadd at aol.com zzbbaadd at aol.com
Thu Aug 30 15:17:26 EDT 2007


On Aug 30, 12:13 pm, Arnaud Delobelle <arno... at googlemail.com> wrote:
> On Aug 30, 8:00 pm, zzbba... at aol.com wrote:
>
> > I have read that you can derive from the base classes such as str,
> > list, dict.
>
> > I guess this would look like:
>
> > def MyString(str):
> > def MyList(list):
> > def MyDict(dict):
>
> You mean
>
> class MyString(str):
> ...
>
> > How do you access the data that is contained in the super class?
>
> The same way that you access plain strings, lists or dicts: use the
> methods of the super class.
>

I don't know what name I would use to call a method:


class MyString(str):
    def __init__(strInput):
       ????? = strInput





More information about the Python-list mailing list