[Python-Dev] Re: [Python-checkins] python/dist/src/Lib types.py,1.26,1.27

Martin v. Loewis martin@v.loewis.de
24 May 2002 09:35:03 +0200


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

> - The 'new' module may also become deprecated; its functions
>   (instance, instancemethod, function, code, module, and classobj)
>   should be implementable by calling the appropriate types (not all of
>   these are their own factories yet, so that's another task).  Then
>   for compatibility, a module "new.py" may be provided that implements
>   the interfaces in a backward-compatible way.

I think that "new" might be the place where the type objects are
exposed; it's not just the matter of making the types callable, but
also of exposing their names somewhere. Then, in types.py

class _C:
    def _m(self): pass
ClassType = type(_C)
UnboundMethodType = type(_C._m)         # Same as MethodType
_x = _C()
InstanceType = type(_x)
MethodType = type(_x._m)

would become

ClassType = new.classobj
UnboundMethodType = MethodType = new.instancemethod
InstanceType = new.instance

Regards,
Martin