[Python-checkins] CVS: python/nondist/peps pep-0202.txt,1.6,1.7

Barry Warsaw bwarsaw@users.sourceforge.net
2001年8月14日 11:43:08 -0700


Update of /cvsroot/python/python/nondist/peps
In directory usw-pr-cvs1:/tmp/cvs-serv2465
Modified Files:
	pep-0202.txt 
Log Message:
We have assumed control, we have assumed control, we have assumed
control.
Clean this PEP up to reflect current reality, and mark it Final.
Index: pep-0202.txt
===================================================================
RCS file: /cvsroot/python/python/nondist/peps/pep-0202.txt,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** pep-0202.txt	2000年10月30日 20:48:44	1.6
--- pep-0202.txt	2001年08月14日 18:43:06	1.7
***************
*** 2,7 ****
 Title: List Comprehensions
 Version: $Revision$
! Author: tim@digicool.com (Tim Peters)
! Status: Draft
 Type: Standards Track
 Python-Version: 2.0
--- 2,7 ----
 Title: List Comprehensions
 Version: $Revision$
! Author: barry@zope.com (Barry Warsaw)
! Status: Final
 Type: Standards Track
 Python-Version: 2.0
***************
*** 52,58 ****
 >>> print [(i,f) for i in nums for f in fruit if f[0] == "P" if i%2 == 1]
 [(1, 'Peaches'), (1, 'Pears'), (3, 'Peaches'), (3, 'Pears')]
- >>> def zip(*args):
- ... return apply(map, (None,)+args)
- ... 
 >>> print [i for i in zip(nums,fruit) if i[0]%2==0]
 [(2, 'Peaches'), (4, 'Bananas')]
--- 52,55 ----
***************
*** 61,76 ****
 Reference Implementation
 
! SourceForge contains a patch that adds list comprehensions to Python[1].
 
 
 BDFL Pronouncements
 
- Note: the BDFL refers to Guido van Rossum, Python's Benevolent
- Dictator For Life.
- 
 - The syntax proposed above is the Right One.
 
! - The form [x, y for ...] should be disallowed; one should be
! required to write [(x, y) for ...].
 
 - The form [... for x... for y...] nests, with the last index
--- 58,71 ----
 Reference Implementation
 
! List comprehensions become part of the Python language with
! release 2.0, documented in [1].
 
 
 BDFL Pronouncements
 
 - The syntax proposed above is the Right One.
 
! - The form [x, y for ...] is disallowed; one is required to write
! [(x, y) for ...].
 
 - The form [... for x... for y...] nests, with the last index
***************
*** 78,135 ****
 
 
- Open Issues
- 
- Syntax
- 
- Several people proposed connecting or separating syntax
- between the various clauses, for example, requiring a
- semicolon between them to set them apart:
- 
- [i,f; for i in nums; for f in fruit; if f[0]=="P"; if i%2==1]
- 
- To minimize strain on the Python parser, Guido has suggested
- requiring parentheses around the initial tuple:
- 
- [(i,f) for i in nums for f in fruit if f[0]=="P" if i%2==1]
- 
- Semantics
- 
- The semantics of multiple for clauses is not obvious to many
- people. Currently, it nests, so that
- 
- [i,f for i in nums for f in fruit]
- 
- is functionally equivalent to
- 
- tmp = []
- for i in nums:
- for f in fruit:
- tmp.append((i,f))
- 
- Other people would read it as if it executed
- 
- map(None, nums, fruit)
- 
- It's not clear that this is necessary. The newly proposed
- zip() builtin[2] takes care of that case.
- 
- Stability of the Implementation
- 
- The current reference implementation is simply an adaptation
- of Greg Ewing's original demonstration of the concept. Other
- than tracking changes to the source code to keep it a valid
- patch, reindenting the code and switching to function
- prototypes, nothing has been done to it. This obviously
- raises some questions about how stable the code is. It has
- not had a lot of exercise, though the patch does include a few
- test cases.
- 
- 
 References
 
! [1] https://sourceforge.net/patch/?func=detailpatch&patch_id=100654&group_id=5470
! [2] Lockstep Iteration, pep-0201.txt
 
 
 Local Variables:
 mode: indented-text
--- 73,82 ----
 
 
 References
 
! [1] http://www.python.org/doc/current/ref/lists.html#l2h-238
 
 
+ 
 Local Variables:
 mode: indented-text

AltStyle によって変換されたページ (->オリジナル) /