[Python-Dev] Classes that claim to be defined in __builtin__ but aren't

Brett C. bac at OCF.Berkeley.EDU
Sun Aug 15 08:09:09 CEST 2004


Guido van Rossum wrote:

>>Sooo should (for 'generator' in objects that claim to be in 
>>__builtins__ but aren't),
>>1) 'generator' be added to __builtins__
>>2) 'generator' be added to types.py and its __module__ be set to 'types'
>>3) 'generator' be added to <newmodule>.py and its __module__ be set to 
>>'<newmodule>' (and a name for the module chosen)
> 
> 
> I guess (1).
> 

The problem I see with explicitly adding this stuff to __builtins__ is 
that tab-completion in the interpreter is suddenly going to have all of 
this extra stuff that people are not going want to really see that often.

The other point I would like to make is that almost everything in 
__builtins__ is either an exception, a singleton (thinking of True and 
False), or a function (even thinking of list and dict since you can use 
their factory methods).  The only exceptions I can think of are __name__ 
and that is just part of the design.  Throwing in generator and any of 
the other types that are defined by the built-in types will go against 
all of this unless we create factory methods for them which is not 
really desired since they are returned only in certain situations.

I personally prefer option 2.

-Brett


More information about the Python-Dev mailing list