[Python-checkins] python/nondist/peps pep-0294.txt,NONE,1.1 pep-0000.txt,1.188,1.189

bwarsaw@users.sourceforge.net bwarsaw@users.sourceforge.net
Sun, 23 Jun 2002 16:52:21 -0700


Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv29951

Modified Files:
	pep-0000.txt 
Added Files:
	pep-0294.txt 
Log Message:
Added PEP 294, Type Names in the types Module, Oren Tirosh


--- NEW FILE: pep-0294.txt ---
PEP: 294
Title: Type Names in the types Module
Version: $Revision: 1.1 $
Last-Modified: $Date: 2002/06/23 23:52:19 $
Author: oren at hishome.net (Oren Tirosh)
Status: Draft
Type: Standards track
Created: 19-Jun-2002
Python-Version: 2.3
Post-History:


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.

    With this change the types module can serve as a replacement for
    the new module.  The new module shall be deprecated and listed in
    PEP 4.


Rationale

    Using two sets of names for the same objects is redundant and
    confusing.

    In Python versions prior to 2.2 the symbols matching many type
    names were taken by the factory functions for those types.  Now
    all basic types have been unified with their factory functions and
    therefore the type names are available to be consistently used to
    refer to the type object.

    Most types are accessible as either builtins or in the new module
    but some types such as traceback and generator are only accssible
    through the types module under names which do not match the type
    name.  This PEP provides a uniform way to access all basic types
    under a single set of names.


Specification

    The types module shall pass the following test:

        import types
        for t in vars(types).values():
            if type(t) is type:
                assert getattr(types, t.__name__) is t

    The types 'class', 'instance method' and 'dict-proxy' have already
    been renamed to the valid Python identifiers 'classobj',
    'instancemethod' and 'dictproxy', making this possible.


Backward compatibility

    Because of their widespread use it is not planned to actually
    remove the long names from the types module in some future
    version.  However, the long names should be changed in
    documentation and library sources to discourage their use in new
    code.


Reference Implementation
 
    A reference implementation is available in SourceForge patch
    #569328: http://www.python.org/sf/569328
  

Copyright

    This document has been placed in the public domain.



Local Variables:
mode: indented-text
indent-tabs-mode: nil
sentence-end-double-space: t
fill-column: 70
End:

Index: pep-0000.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v
retrieving revision 1.188
retrieving revision 1.189
diff -C2 -d -r1.188 -r1.189
*** pep-0000.txt	19 Jun 2002 03:22:24 -0000	1.188
--- pep-0000.txt	23 Jun 2002 23:52:19 -0000	1.189
***************
*** 98,101 ****
--- 98,102 ----
   S   292  Simpler String Substitutions                 Warsaw
   S   293  Codec Error Handling Callbacks               Dörwald
+  S   294  Type Names in the types Module               Tirosh
  
   Finished PEPs (done, implemented in CVS)
***************
*** 276,279 ****
--- 277,281 ----
   S   292  Simpler String Substitutions                 Warsaw
   S   293  Codec Error Handling Callbacks               Dörwald
+  S   294  Type Names in the types Module               Tirosh
   SR  666  Reject Foolish Indentation                   Creighton
  
***************
*** 336,339 ****
--- 338,342 ----
      Schneider-Kamp, Peter    nowonder@nowonder.de
      Stein, Greg              gstein@lyra.org
+     Tirosh, Oren             oren at hishome.net
      Warsaw, Barry            barry@zope.com
      Wilson, Greg             gvwilson@ddj.com