[Python-Dev] Why are there no 'set' and 'frozenset' types in the 'types' module?

Fred Drake fdrake at acm.org
Mon Apr 25 15:01:36 CEST 2011


On Mon, Apr 25, 2011 at 8:04 AM, haael <haael at interia.pl> wrote:
> Sorry if I am asking the obvious, but why are the aliases of set types not
> included in the 'types' module? I thought for a moment that they are just
> classes, but no, they introduce themselves as built-in types, just like any
> other standard Python type.

The types module pre-dates the time when classes were actually types in their
own right, and many of the built-in constructors, like "float", "int", and
"list", were simply functions.  When that was the case:

    >>> import types
    >>> types.IntType == int
    False

For types that have always been types, there's no corresponding entry in the
types module, nor is there any need for any, since the type itself is already
accessible.


  -Fred

-- 
Fred L. Drake, Jr.    <fdrake at acm.org>
"Give me the luxuries of life and I will willingly do without the necessities."
   --Frank Lloyd Wright


More information about the Python-Dev mailing list