On 2010-05-26, José Matos wrote:
> On Wednesday 26 May 2010 15:29:13 Pavel Sanda wrote:
>> can you be even more verbose abou the "subtle" problems?
>> my imagination was that there exists pythonic code running under both 2 & 3
>> so once we convert the code we dont need to care anymore about
>> versioning...

> What would it be the minimum version required on the 2.x side?

> Currently we support from 2.3.4 up to the latest 2.7 beta

> It is more or less easy to have running code for python 2.6 and 3.1, the 
> further down you go to older version the difficult it comes.

For code that should work with both Python 2 and 3, the Python docs
recommend maintaining a Python-2 version and auto-converting to Python-3
code with the 2to3.py script. This can be made part of the install
routine, e.g. in a setup.py script.

> One example in python 2.x

> 5/2 == 2

> on python 3.x you get

> 5/2 == 2.5 (as much as equality tests are appropriate for floating point 
> operations)

Another tricky point (and more important for the LyX Python scripts) is
the 8-bit vs. Unicode nature of strings:

In Python 2, strings are 8-bit, unless explicitely converted to Unicode
(with the .decode() method) or given as u"something" string literal.

In Python 3, strings are Unicode, unless explicitely converted to binary
or givne as b"something" string literal.

Hence, reading a file will result in a binary string in Python 2 and a
Unicode string in Python 3 which brings subtle problems especially with
error handling.

My conclusion: it can be done, however it is a burden we should only take
on if really necessary. To me, it seems that most systems still have a
2.x version available.

Günter


Reply via email to