Type hierarchy

Gerrit Holl gerrit at nl.linux.org
Fri Jun 13 10:32:44 EDT 2003


Hi,

currently, almost all types directly inherit from object. The only
exceptions are string and unicode, which inherit from basestring.
But wouldn't a type hierarchy be very useful for other types as
well? For example, checking whether something is a number, currently
needs isinstance(o, int) or isinstance(o, long), or float... although
ints and longs are going to be the same. Would it be wise to let those
have common base types?

For example:

object
 |
 +-- sequence
 |    |
 |    +-- immutable
 |    |    |
 |    |    +-- basestring
 |    |    |    |
 |    |    |    +-- string
 |    |    |    +-- unicode
 |    |    |
 |    |    +-- tuple
 |    |
 |    +-- mutable
 |         |
 |         +-- list
 |         +-- array
 |
 +-- mapping
 |    |
 |    +-- dict
 |
 +-- number
 |    |
 |    +-- int
 |         +-- bool
 |    +-- long
 |    +-- float
 |    +-- complex
 |
 +-- internal
      |
      +-- code
      +-- frame
      +-- traceback

...etc. Could this possibly be a good idea? Is it PEP-worthy?

yours,
Gerrit.

-- 
198. If he put out the eye of a freed man, or break the bone of a freed
man, he shall pay one gold mina.
        -- 1780 BC, Hammurabi, Code of Law
--
Asperger Syndroom - een persoonlijke benadering:
	http://people.nl.linux.org/~gerrit/
Het zijn tijden om je zelf met politiek te bemoeien:
	http://www.sp.nl/





More information about the Python-list mailing list