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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4