Type hierarchy

Russ Salsbury clpy.NOSPAM at russellsalsbury.com
Fri Jun 13 14:24:36 EDT 2003


Gerrit Holl <gerrit at nl.linux.org> wrote in message news:<mailman.1055514878.28221.python-list at python.org>...
> 
> For example:
> 
> object
>  |
>  +-- sequence
>  |    |
>  +-- immutable
>  |    |    |
>  +-- basestring
>  |    |    |    |
>  |    |    |    +-- string
>  |    |    |    +-- unicode
>  |    |    |
>  |    |    +-- tuple
>  |    |
>  |    +-- mutable
>  |         |
>  |         +-- list
>  |         +-- array
...

I think the type hierarchy in Python is a mess and should be repaired.
 If it is possible to set up a CLASS hierarchy independent of the type
hierarchy, which fixes the problems, then I'm all for it.  If the type
hierarchy can be fixed, even better.

The probelem is that strings are under sequences.  In all other
languages that I am familiar with, sequences are collections and
strings are something different, usually primitives or scalars.  I'm
sure a fair number of us have checked a function parameter for type
sequence, only to find that strings pass through unscathed.

I think collections should come under a Collection type/class

    Collection
         Sequence
             tuple
             list
         Mapping
             dict

and strings should go elsewhere.

Immutable should be orthogonal to the class hierachy.

Russ




More information about the Python-list mailing list