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

Oren Tirosh oren-py-d@hishome.net
Tue, 25 Jun 2002 01:02:10 -0400


On Tue, Jun 25, 2002 at 12:09:38AM +0100, Michael Hudson wrote:
> Oren Tirosh <oren-py-l@hishome.net> writes:
> 
> > Abstract
> > 
> >     This PEP proposes that symbols matching the type name should be
> >     added to the types module for all basic Python types in the types
> >     module:
> > 
> >         types.IntegerType -> types.int
> >         types.FunctionType -> types.function
> >         types.TracebackType -> types.traceback
> >          ...    
> > 
> >     The long capitalized names currently in the types module will be
> >     deprecated.
> 
> Um, can I be a little confused?  If you are writing code that you know
> will be run in 2.2 and later, you write
> 
>    isinstance(obj, int)
> 
> If you want to support 2.1 and so on, you write 
> 
>    isinstance(obj, types.IntType)
> 
> What would writing 
> 
>    isinstance(obj, types.int)
> 
> ever gain you except restricting execution to 2.3+?

It's like asking what do you gain by using string methods instead of the 
string module.  It's part of a slow, long-term effort to clean up the 
language while trying to minimize the impact on existing code.

	Oren