[Python-3000] PEP 3113 transition plan (original) (raw)
Collin Winter collinw at gmail.com
Wed Mar 7 01:43:35 CET 2007
- Previous message: [Python-3000] string formatting and locals() (WAS: locals(), closures, and IronPython...)
- Next message: [Python-3000] PEP 3113 transition plan
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From the checked-in version,
""" Two additional transformations will be added to the 2to3 translation tool [3]:
* Method definitions named next will be renamed to __next__.
* Explicit calls to the next method will be replaced with calls to
the built-in next function. For example, x.next() will become next(x).
If the module being processed already contains a binding for the name next, the second transformation will not be done; instead, calls to x.next() will be replaced with x.next() and a warning will be emitted. (Collin Winter has looked into this [4] and found that it's difficult to make the second transformation depend on the presence of a module-level binding; warning about the existence of bindings to next should be possible, though.) """
I'd like to strike the part about making "x.next()" -> "next(x)"/"x.next()" determined by the presence of a module-level "next" binding. I'd rather see the transformation always be "x.next()" -> "next(x)" and warn on top-level "next"s. Doing it the way the PEP suggests is possible, but ugly (requires an unusually-complicated fixer) and slow. I can give you warnings on the following items, though:
- global assignments to "next".
- global definitions of a "next" function.
- global imports of anything named "next".
- assignments to "builtin.next".
Will that do?
Collin Winter
- Previous message: [Python-3000] string formatting and locals() (WAS: locals(), closures, and IronPython...)
- Next message: [Python-3000] PEP 3113 transition plan
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]