Clarify the transition plan for the 2to3 fixer. Also link directly to the
fixer itself.
This commit is contained in:
parent
1c68c46409
commit
34e9d0f39f
27
pep-3113.txt
27
pep-3113.txt
|
@ -216,13 +216,12 @@ emitted when Python's compiler comes across a tuple parameter in
|
||||||
Python 2.6. This will be treated like any other syntactic change that
|
Python 2.6. This will be treated like any other syntactic change that
|
||||||
is to occur in Python 3.0 compared to Python 2.6.
|
is to occur in Python 3.0 compared to Python 2.6.
|
||||||
|
|
||||||
Second, the 2to3 refactoring tool [#2to3]_ will gain a rule for
|
Second, the 2to3 refactoring tool [#2to3]_ will gain a fixer
|
||||||
translating tuple parameters to being a single parameter that is
|
[#fixer]_ for translating tuple parameters to being a single parameter
|
||||||
unpacked as the first statement in the function. The name of the new
|
that is unpacked as the first statement in the function. The name of
|
||||||
parameter will be a mangling of tuple parameter's names by joining
|
the new parameter will be changed. The new parameter will then be
|
||||||
them with underscores. The new parameter will then be unpacked into
|
unpacked into the names originally used in the tuple parameter. This
|
||||||
the names originally used in the tuple parameter. This means that the
|
means that the following function::
|
||||||
following function::
|
|
||||||
|
|
||||||
def fxn((a, (b, c))):
|
def fxn((a, (b, c))):
|
||||||
pass
|
pass
|
||||||
|
@ -233,6 +232,17 @@ will be translated into::
|
||||||
(a, (b, c)) = a_b_c
|
(a, (b, c)) = a_b_c
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
As tuple parameters are used by lambdas because of the single
|
||||||
|
expression limitation, they must also be supported. This is done by
|
||||||
|
having the expected sequence argument bound to a single parameter and
|
||||||
|
then indexing on that parameter::
|
||||||
|
|
||||||
|
lambda (x, y): x + y
|
||||||
|
|
||||||
|
will be translated into::
|
||||||
|
|
||||||
|
lambda x_y: x_y[0] + x_y[1]
|
||||||
|
|
||||||
|
|
||||||
References
|
References
|
||||||
==========
|
==========
|
||||||
|
@ -240,6 +250,9 @@ References
|
||||||
.. [#2to3] 2to3 refactoring tool
|
.. [#2to3] 2to3 refactoring tool
|
||||||
(http://svn.python.org/view/sandbox/trunk/2to3/)
|
(http://svn.python.org/view/sandbox/trunk/2to3/)
|
||||||
|
|
||||||
|
.. [#fixer] 2to3 fixer
|
||||||
|
(http://svn.python.org/view/sandbox/trunk/2to3/fixes/fix_tuple_params.py)
|
||||||
|
|
||||||
.. [#ironpython] IronPython
|
.. [#ironpython] IronPython
|
||||||
(http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython)
|
(http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue