[Python-checkins] CVS: python/nondist/peps pep-0000.txt,1.58,1.59 pep-0212.txt,1.3,1.4
Peter Schneider-Kamp
python-dev@python.org
Thu, 14 Dec 2000 07:37:29 -0800
Update of /cvsroot/python/python/nondist/peps
In directory slayer.i.sourceforge.net:/tmp/cvs-serv14159
Modified Files:
pep-0000.txt pep-0212.txt
Log Message:
Fixed a typo in my email address.
Updated 'Loop counter iteration' PEP 212.
Index: pep-0000.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0000.txt,v
retrieving revision 1.58
retrieving revision 1.59
diff -C2 -r1.58 -r1.59
*** pep-0000.txt 2000/12/13 02:14:11 1.58
--- pep-0000.txt 2000/12/14 15:37:25 1.59
***************
*** 160,164 ****
van Rossum, Guido guido@python.org
Schemenauer, Neil nas@arctrix.com
! Schneider-Kamp, Peter nownder@nowonder.de
Warsaw, Barry barry@digicool.com
Wilson, Greg gvwilson@nevex.com
--- 160,164 ----
van Rossum, Guido guido@python.org
Schemenauer, Neil nas@arctrix.com
! Schneider-Kamp, Peter nowonder@nowonder.de
Warsaw, Barry barry@digicool.com
Wilson, Greg gvwilson@nevex.com
Index: pep-0212.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0212.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** pep-0212.txt 2000/08/23 05:06:22 1.3
--- pep-0212.txt 2000/12/14 15:37:25 1.4
***************
*** 5,10 ****
Status: Draft
Type: Standards Track
- Python-Version: 2.1
Created: 22-Aug-2000
--- 5,10 ----
Status: Draft
Type: Standards Track
Created: 22-Aug-2000
+ Python-Version: 2.1
***************
*** 53,64 ****
The Proposed Solutions
! There are two solutions that have been discussed. One adds a
non-reserved keyword, the other adds two built-in functions.
- A third solution would have been the addition of 'keys', 'items'
- and 'values' methods to sequences, which enable looping over
- indices only, both indices and elements, and elements only
- respectively.
-
Non-reserved keyword 'indexing'
--- 53,60 ----
The Proposed Solutions
! There are three solutions that have been discussed. One adds a
non-reserved keyword, the other adds two built-in functions.
+ A third solution adds methods to sequence objects.
Non-reserved keyword 'indexing'
***************
*** 104,107 ****
--- 100,148 ----
+ Methods for sequence objects
+
+ This solution proposes the addition of 'indices', 'items'
+ and 'values' methods to sequences, which enable looping over
+ indices only, both indices and elements, and elements only
+ respectively.
+
+ This would immensely simplify the idioms for looping over indices
+ and for looping over both elements and indices:
+
+ for i in sequence.indices():
+ # work with index i
+
+ for i, e in sequence.items():
+ # work with index i and element e
+
+ Additionally it would allow to do looping over the elements
+ of sequences and dicitionaries in a consistent way:
+
+ for e in sequence_or_dict.values():
+ # do something with element e
+
+
+ Implementations
+
+ For all three solutions some more or less rough patches exist
+ as patches at SourceForge:
+
+ 'for i indexing a in l': exposing the for-loop counter[3]
+ add indices() and irange() to built-ins[4]
+ add items() method to listobject[5]
+
+ All of them have been pronounced on and rejected by the BDFL.
+
+ Note that the 'indexing' keyword is only a NAME in the
+ grammar and so does not hinder the general use of 'indexing'.
+
+
+ Backward Compatibility Issues
+
+ As no keywords are added and the semantics of existing code
+ remains unchanged, all three solutions can be implemented
+ without breaking existing code.
+
+
Copyright
***************
*** 113,116 ****
--- 154,160 ----
[1] http://www.python.org/doc/current/ref/for.html
[2] Lockstep Iteration, pep-0201.txt
+ [3] http://sourceforge.net/patch/download.php?id=101138
+ [4] http://sourceforge.net/patch/download.php?id=101129
+ [5] http://sourceforge.net/patch/download.php?id=101178