[Python-Dev] PEP 294: Type Names in the types Module

Jeremy Hylton jeremy@zope.com
Fri, 12 Jul 2002 12:06:25 -0400


>>>>> "GvR" == Guido van Rossum <guido@python.org> writes:

  >> > If we need a place to name types that don't deserve being
  >> > builtins, perhaps new.py is a better place?
  >>
  >> The new. prefix is natural enough for
  >>
  >> m = new.module('name')
  >>
  >> type but it looks pretty awkward in
  >>
  >> if isinstance(obj, new.generator):
  >>
  >> What's the meaning of 'new' in this context?

  GvR> Sometimes you ask too many questions. :-)

  GvR> Let's just say that this is a historically available name.  I
  GvR> don't expect that isinstance(obj, generator) is a very common
  GvR> question to ask, so I don't mind if you have to ask it in a
  GvR> somewhat awkward way.

I recently wrote some code that needed to look for functions.  I wrote
it this way:

from new import function

# ...

if isinstance(obj, function):
    # ...

It didn't look odd at all.  And I don't care much where I import
function from.  I wouldn't mind if all the type objects defined in new
where available in types.  IOW, the names exported by new could also
be exported by types.

This means types would fall into two categories: types with builtin
names and types available in the types module.  I expect the current
set of types with builtin names is sufficient.

Jeremy