[Python-Dev] Classes that claim to be defined in builtin but aren't (original) (raw)

Jim Fulton jim at zope.com
Tue Aug 10 00:16:53 CEST 2004


James Y Knight wrote:

There's a fair number of classes that claim they are defined in builtin, but do not actually appear there. For example:

>>> def qual(clazz): ... return clazz.module + '.' + clazz.name ... >>> qual(types.GeneratorType) 'builtin.generator' >>> qual(types.FunctionType) 'builtin.function' >>> qual(types.MethodType) 'builtin.instancemethod' >>> qual(types.NoneType) 'builtin.NoneType' >>> qual(types.GeneratorType) 'builtin.generator' >>> builtin.generator AttributeError: 'module' object has no attribute 'generator' [[[etc.]]] IMO classes ought to actually appear in builtin if they claim they are defined there. Doing otherwise breaks reflection, as you have to add a special case for these class names to use the appropriate object from the types module instead. Thoughts?

I agree.

If it isn't desirable to have these names appear in builtin, perhaps their 'module' should be changed to another module where they are defined?

+1

Jim

-- Jim Fulton mailto:jim at zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org



More information about the Python-Dev mailing list