[Python-3000] Cross-compatibility with 2.6 and 3.0
Talin
talin at acm.org
Fri Mar 9 00:18:42 CET 2007
Guido's Py3K presentation of February 14th (available on Google Video at
this URL: http://video.google.com/videoplay?docid=1189446823303316785)
contains the following statement:
"It is unlikely that you will be able to write both code that is both
valid Python 2.6 source code and valid Python 3.0 source code".
This seems like a big problem to me: From a systems management approach,
its much easier to migrate a system if you can take a gradualist
approach rather than being forced to maintain two versions of the code
in parallel. It means that you can continue to test your working program
as you update each module, rather than trying to do the whole thing in
one gulp and then try to figure out what broke.
I know that a lot of Python 3K feature will be back-ported to 2.X.
What's missing? What stands in the way of me creating a version of my
code that runs under both?
For example, take the print statement: Clearly, the two uses of 'print'
are incompatible. But nothing says that I actually have to use 'print'
in my code - I can write a wrapper around the old 'print' that works
just like the new 'print', as long as I name it something different than
'print'. Later, when I cut the tie to 2.X, I can do a mass rename of
that function back to 'print'.
Or, conversely, we could have a __future__ import that simply removes
the 'print' keyword from the language.
Similarly, the syntax of the 'except' statement is different - but I
don't see why 2.6 couldn't support both forms; The presence of the 'as'
keyword is a dead giveaway that you are using the new form. Or, again, a
__future__ import could work as well.
-- Talin
More information about the Python-3000
mailing list