[Python-checkins] peps: Integrated many suggestions from c.l.py and others. Nothing (original) (raw)
georg.brandl python-checkins at python.org
Wed Mar 23 21:24:02 CET 2011
- Previous message: [Python-checkins] peps: Added PEP 216, Docstring Format, assigned to Moshe Zadka
- Next message: [Python-checkins] peps: PEP 211 renamed to "Adding New Linear Algebra Operators" at request of
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
http://hg.python.org/peps/rev/7775a6117a48 changeset: 68:7775a6117a48 user: Barry Warsaw <barry at python.org> date: Mon Jul 31 15:52:45 2000 +0000 summary: Integrated many suggestions from c.l.py and others. Nothing substantial w.r.t. the proposed solution, just clarifications, additional references, and an explanation of why most syntax changes don't work.
files: pep-0201.txt | 52 ++++++++++++++++++++++++--------------- 1 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/pep-0201.txt b/pep-0201.txt --- a/pep-0201.txt +++ b/pep-0201.txt @@ -10,14 +10,14 @@
Introduction
- This PEP describes the `lockstep iteration' proposal for Python
- 2.0. This PEP tracks the status and ownership of this feature,
- slated for introduction in Python 2.0. It contains a description
- of the feature and outlines changes necessary to support the
- feature. This PEP summarizes discussions held in mailing list
- forums, and provides URLs for further information, where
- appropriate. The CVS revision history of this file contains the
- definitive historical record.
- This PEP describes the `lockstep iteration' proposal. This PEP
- tracks the status and ownership of this feature, slated for
- introduction in Python 2.0. It contains a description of the
- feature and outlines changes necessary to support the feature.
- This PEP summarizes discussions held in mailing list forums, and
- provides URLs for further information, where appropriate. The CVS
- revision history of this file contains the definitive historical
- record.
Motivation @@ -25,13 +25,17 @@ Standard for-loops in Python iterate over every element in a sequence until the sequence is exhausted[1]. However, for-loops iterate over only a single sequence, and it is often desirable to
- loop over more than one sequence, in a lock-step, "Chinese Menu"
- type of way.
- loop over more than one sequence in a lock-step fashion. In other
- words, in a way such that nthe i-th iteration through the loop
- returns an object containing the i-th element from each sequence.
- The common idioms used to accomplish this are unintuitive and
- inflexible. This PEP proposes a standard way of performing such
- iterations by introducing a new builtin function called `zip'.
The common idioms used to accomplish this are unintuitive. This
PEP proposes a standard way of performing such iterations by
introducing a new builtin function called `zip'.
While the primary motivation for zip() comes from lock-step
iteration, by implementing zip() as a built-in function, it has
additional utility in contexts other than for-loops.
Lockstep For-Loops
@@ -70,13 +74,20 @@ [(1, 4), (2, 5), (3, 6), (None, 7)]
For these reasons, several proposals were floated in the Python
- 2.0 beta time frame for providing a better spelling of lockstep
- for-loops. The initial proposals centered around syntactic
- changes to the for statement, but conflicts and problems with the
- syntax were unresolvable, especially when lockstep for-loops were
- combined with another proposed feature called `list
- comprehensions' (see pep-0202.txt).
2.0 beta time frame for syntactic support of lockstep for-loops.
Here are two suggestions:
for x in seq1, y in seq2:
# stuff
for x, y in seq1, seq2:
# stuff
Neither of these forms would work, since they both already mean
something in Python and changing the meanings would break existing
code. All other suggestions for new syntax suffered the same
problem, or were in conflict with other another proposed feature
called `list comprehensions' (see pep-0202.txt).
The Proposed Solution
@@ -206,7 +217,8 @@ [1] http://www.python.org/doc/current/ref/for.html [2] http://www.haskell.org/onlinereport/standard-prelude.html#$vzip
- TBD: URL to python-dev archives
- Greg Wilson's questionaire on proposed syntax to some CS grad students
- http://www.python.org/pipermail/python-dev/2000-July/013139.html
Copyright
-- Repository URL: http://hg.python.org/peps
- Previous message: [Python-checkins] peps: Added PEP 216, Docstring Format, assigned to Moshe Zadka
- Next message: [Python-checkins] peps: PEP 211 renamed to "Adding New Linear Algebra Operators" at request of
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]