[Python-checkins] python/nondist/peps pep-0322.txt,1.10,1.11

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Sun Nov 2 02:12:06 EST 2003


Update of /cvsroot/python/python/nondist/peps
In directory sc8-pr-cvs1:/tmp/cvs-serv16525

Modified Files:
	pep-0322.txt 
Log Message:
Three PEP updates:

* Correct the pure python implementation.
* Link to an implementation patch on SF.
* Remove the proposed application of __reverse__ to enumerate().



Index: pep-0322.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0322.txt,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** pep-0322.txt	30 Oct 2003 07:41:20 -0000	1.10
--- pep-0322.txt	2 Nov 2003 07:12:04 -0000	1.11
***************
*** 68,76 ****
  
      def reversed(x):
!         try:
!             return x.__reversed__()
!         except AttributeError:
!             pass
!         if hasattr(x, "has_key"):
              raise ValueError("mappings do not support reverse iteration")
          i = len(x)
--- 68,75 ----
  
      def reversed(x):
!         if hasattr(x, 'reversed'):
!             for elem x.__reversed__():
! 		yield x
!         if hasattr(x, 'keys'):
              raise ValueError("mappings do not support reverse iteration")
          i = len(x)
***************
*** 82,85 ****
--- 81,86 ----
  compatible.
  
+ A C implementation and unit tests are at:  http://www.python.org/sf/834422
+ 
  
  Alternative Method Names
***************
*** 102,111 ****
  __getitem__() and __len__() but still have some useful way of
  providing reverse iteration.
- 
- For example, using this protocol, *enumerate()* can be extended to 
- support reversal whenever the underlying iterator supports it also::
- 
-     >>> list(reversed(enumerate("abc")))
-     [(2, 'c'), (1, 'b'), (0, 'a')]
  
  
--- 103,106 ----





More information about the Python-checkins mailing list