
I have been developing in Python since 1.5, and now have to support 2.1 as a minimum version. I do like to keep my code runnable on newer versions however, and am considering the feasability of forward compatibility with Python 3.0. I also notice the Leo[1] project could use some assistance with forward compatibility. So I was wondering if anyone else had a need for a 2to23.py tool to help make code compatible with 3.0 but not break it for 2.x. Such a tool could also include implementations of new builtins added in python 3.0, or work in tandem with a "py3to2" library. One such function would be "print" (which would have to be renamed to e.g. "prints" as "def print()" is a syntax error in 2.x). This would have the added benefit of staunching the flow of wasted effort into many differing implementations of such things, and maybe direct some of it into development of this tool. Hope this is on topic, and has not already been considered and dismissed. Thanks, Graham [1] http://webpages.charter.net/edreamleo/front.html P.S. a suggested prints() implementation for py3to2.py, including raising a TypeError exception for extra keyword args, and returning None. It works in python 2.1 through to python 3.0a1. def prints(*args, **kw): kw.setdefault('sep', ' ') kw.setdefault('end', '\n') kw.setdefault('file', sys.stdout) if len(kw) > 3: for k in ('sep', 'end', 'file'): del kw[k] if len(kw) > 1: raise TypeError(', '.join(map(repr, kw.keys())) + ' are invalid keyword arguments for this function') else: raise TypeError('%r is an invalid keyword argument for this function' % list(kw.keys())[0]) kw['file'].write(kw['sep'].join(['%s' % a for a in args]) + kw['end'])

On Nov 11, 2007 4:00 PM, Graham Horler <graham.horler@gmail.com> wrote:
I have been developing in Python since 1.5, and now have to support 2.1 as a minimum version. I do like to keep my code runnable on newer versions however, and am considering the feasability of forward compatibility with Python 3.0.
I also notice the Leo[1] project could use some assistance with forward compatibility.
So I was wondering if anyone else had a need for a 2to23.py tool to help make code compatible with 3.0 but not break it for 2.x.
What exactly are you proposing? We already have 2to3 (http://svn.python.org/view/sandbox/trunk/2to3/) for source-to-source translation from 2.x to 3.0. -Brett

Op zondag 11-11-2007 om 17:19 uur [tijdzone -0800], schreef Brett Cannon:
On Nov 11, 2007 4:00 PM, Graham Horler <graham.horler@gmail.com> wrote:
I have been developing in Python since 1.5, and now have to support 2.1 as a minimum version. I do like to keep my code runnable on newer versions however, and am considering the feasability of forward compatibility with Python 3.0.
I also notice the Leo[1] project could use some assistance with forward compatibility.
So I was wondering if anyone else had a need for a 2to23.py tool to help make code compatible with 3.0 but not break it for 2.x.
What exactly are you proposing? We already have 2to3 (http://svn.python.org/view/sandbox/trunk/2to3/) for source-to-source translation from 2.x to 3.0.
Graham wants to convert his code such that it works on both Python 2.x (probably even early versions of it?) & Python 3.x. Not 2 instances of code, but one source that works on both 2.x and 3.x... -- Jan Claeys

On 12 Nov 2007, 03:24:34, Jan Claeys wrote:
Op zondag 11-11-2007 om 17:19 uur [tijdzone -0800], schreef Brett Cannon:
On Nov 11, 2007 4:00 PM, Graham Horler <graham.horler@gmail.com> wrote:
I have been developing in Python since 1.5, and now have to support 2.1 as a minimum version. I do like to keep my code runnable on newer versions however, and am considering the feasability of forward compatibility with Python 3.0.
I also notice the Leo[1] project could use some assistance with forward compatibility.
So I was wondering if anyone else had a need for a 2to23.py tool to help make code compatible with 3.0 but not break it for 2.x.
What exactly are you proposing? We already have 2to3 (http://svn.python.org/view/sandbox/trunk/2to3/) for source-to-source translation from 2.x to 3.0.
Graham wants to convert his code such that it works on both Python 2.x (probably even early versions of it?) & Python 3.x. Not 2 instances of code, but one source that works on both 2.x and 3.x...
Absolutely

On Nov 12, 2007 12:50 AM, Graham Horler <graham.horler@gmail.com> wrote:
On 12 Nov 2007, 03:24:34, Jan Claeys wrote:
Op zondag 11-11-2007 om 17:19 uur [tijdzone -0800], schreef Brett Cannon:
On Nov 11, 2007 4:00 PM, Graham Horler <graham.horler@gmail.com> wrote:
I have been developing in Python since 1.5, and now have to support 2.1 as a minimum version. I do like to keep my code runnable on newer versions however, and am considering the feasability of forward compatibility with Python 3.0.
I also notice the Leo[1] project could use some assistance with forward compatibility.
So I was wondering if anyone else had a need for a 2to23.py tool to help make code compatible with 3.0 but not break it for 2.x.
What exactly are you proposing? We already have 2to3 (http://svn.python.org/view/sandbox/trunk/2to3/) for source-to-source translation from 2.x to 3.0.
Graham wants to convert his code such that it works on both Python 2.x (probably even early versions of it?) & Python 3.x. Not 2 instances of code, but one source that works on both 2.x and 3.x...
Absolutely
Well, we will do our best to make a common base between 2.6 and 3.0. But since things are still in flux who knows if everything can somehow be added through a __future__ statement in 2.6. As for supporting older versions, that won't happen. -Brett

On Nov 12, 2007 12:50 AM, Graham Horler <graham.horler@gmail.com> wrote:
On 12 Nov 2007, 03:24:34, Jan Claeys wrote:
Op zondag 11-11-2007 om 17:19 uur [tijdzone -0800], schreef Brett Cannon:
On Nov 11, 2007 4:00 PM, Graham Horler <graham.horler@gmail.com> wrote:
I have been developing in Python since 1.5, and now have to support 2.1 as a minimum version. I do like to keep my code runnable on newer versions however, and am considering the feasability of forward compatibility with Python 3.0.
I also notice the Leo[1] project could use some assistance with forward compatibility.
So I was wondering if anyone else had a need for a 2to23.py tool to help make code compatible with 3.0 but not break it for 2.x.
What exactly are you proposing? We already have 2to3 (http://svn.python.org/view/sandbox/trunk/2to3/) for source-to-source translation from 2.x to 3.0.
Graham wants to convert his code such that it works on both Python 2.x (probably even early versions of it?) & Python 3.x. Not 2 instances of code, but one source that works on both 2.x and 3.x...
Absolutely
I don't believe that's possible. There are enough key differences between the two that having the same body of code work in both 2.x and 3.x would require an extensive, complicated runtime support system that no-one has all(the ability, the time, the motivation) to implement. And of course, even if you had such a system, the generated code wouldn't look anything like well-formed Python and would be a maintenance nightmare. Collin Winter

Collin Winter wrote:
On Nov 12, 2007 12:50 AM, Graham Horler <graham.horler@gmail.com> wrote:
On 12 Nov 2007, 03:24:34, Jan Claeys wrote:
Op zondag 11-11-2007 om 17:19 uur [tijdzone -0800], schreef Brett Cannon:
I have been developing in Python since 1.5, and now have to support 2.1 as a minimum version. I do like to keep my code runnable on newer versions however, and am considering the feasability of forward compatibility with Python 3.0.
I also notice the Leo[1] project could use some assistance with forward compatibility.
So I was wondering if anyone else had a need for a 2to23.py tool to help make code compatible with 3.0 but not break it for 2.x. What exactly are you proposing? We already have 2to3 (http://svn.python.org/view/sandbox/trunk/2to3/) for source-to-source
On Nov 11, 2007 4:00 PM, Graham Horler <graham.horler@gmail.com> wrote: translation from 2.x to 3.0. Graham wants to convert his code such that it works on both Python 2.x (probably even early versions of it?) & Python 3.x. Not 2 instances of code, but one source that works on both 2.x and 3.x... Absolutely
I don't believe that's possible. There are enough key differences between the two that having the same body of code work in both 2.x and 3.x would require an extensive, complicated runtime support system that no-one has all(the ability, the time, the motivation) to implement. And of course, even if you had such a system, the generated code wouldn't look anything like well-formed Python and would be a maintenance nightmare.
Besides which, the migration path is already well-specified: write in 3.x-compatible 2.6 and use 2to3 to migrate the code with no further processing. This does eventually give you a single code base. Earlier versions need not apply - there is no way to accommodate them. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/

On Nov 11, 2007 7:24 PM, Jan Claeys <lists@janc.be> wrote:
Graham wants to convert his code such that it works on both Python 2.x (probably even early versions of it?) & Python 3.x. Not 2 instances of code, but one source that works on both 2.x and 3.x...
The transition strategy for 3.0 explicitly excludes this possibility. For example, you couldn't catch exceptions with an error variable, because the except clause syntax changed. You couldn't use print except to print a single string. You couldn't use unicode string literals; you couldn't distinguish between text and binary data in a meaningful way. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (6)
-
Brett Cannon
-
Collin Winter
-
Graham Horler
-
Guido van Rossum
-
Jan Claeys
-
Steve Holden