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 -- http://mail.python.org/mailman/listinfo/python-list