[Python-3000] how to transition 2.X code to 3.0 code
Steven Bethard
steven.bethard at gmail.com
Fri Mar 24 19:20:13 CET 2006
On 3/24/06, Fredrik Lundh <fredrik at pythonware.com> wrote:
> I'm well aware that Python 3000 doesn't aim to be backwards compatible,
> but I would prefer if we could refrain from subtly changing the behaviour
> of existing constructs in way that breaks all existing use, and makes it un-
> necessarily hard to convert old code (whether by hand or by machine).
Agreed. I wonder what the plan is for the transition? Things like
changing the semantics of the for-loop else-clause are actually
relatively easy to flag since they can be spotted easily with the AST,
and *all* current uses of the else-clause would be wrong.
However, flagging things like "expects a list from dict.items instead
of an iterator" might be harder to do. Some uses (for-loops,
list-comps and genexps) are still perfectly fine while other uses
(indexing, getting the len) aren't. I think most of these should
raise an exception pretty quickly, but if any of them don't, that
would make me pretty nervous when transitioning code.
I wonder if it would be worth having a branch of python-3000 at some
point that inserts warning code on all constructs that changed (e.g.
all calls to dict.items). I have a suspicion that this would generate
a lot of false-positives, but maybe it would still be worthwhile...
STeVe
--
Grammar am for people who can't think for myself.
--- Bucky Katt, Get Fuzzy
More information about the Python-3000
mailing list