R. David Murray wrote:
Tuomas Vesterinen <tuomas.vesteri...@iki.fi> wrote:
I am developing a Python application as a Python2.x and Python3.0 version. A common code base would make the work easier. So I thought to try a preprosessor. GNU cpp handles this kind of code correct:

<test_cpp.py>
#ifdef python2
print u'foo', u'bar'
#endif
#ifdef python3
print('foo', 'bar')
#endif
<end code>

results:
 > cpp -E -Dpython2 test_cpp.py
...
print u'foo', u'bar'

Any other suggestions?

There's a Google Summer of Code project to create a 3to2 processor.
That would let you maintain the code in 3.x, and have it automatically
translated on demand so that it will run under 2.x (where x goes back
to at least 5, I think, but I'm not sure).

Of course, it isn't finished yet, so it won't do you any good right at
the moment :(

--
R. David Murray                 http://www.bitdance.com
    IT Consulting    System Administration    Python Programming


I found also a ready made py3to2-tool (test/develop/integrate python 3.0 code natively under robust, software-rich python 2.5 environment) at:
  http://code.activestate.com/recipes/574436/
It seems so complicated that I don't dare to try before some more experienced people has commented it.

TV
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to