Project

General

Profile

Support #103

Updated by Nitesh Mor about 3 years ago

(Originally reported by Pat, but deleted accidentally. Restoring (deleted accidentally, restoring it as much as I can)

We were prepping stuff for the signpost workshop and were surprised that the python deb didn't install bindings for Python 3. Py2k's been deprecated for a while, but the bigger issue is it's handling of low-level byte operations. It's tricky to get that correct in py2k, so we try hard to use python3 wherever/whenever possible.

Running the 2to3 tool on the current gdp sources it looks like it's maybe only ~20 lines that need to change to support py3k, and they're all related to imports.

Maintaining both can bit a bit of a burden, but fortunately you can basically turn py2k into py3k. A common header for everything I do that requires interop is to add this to the top of files:

```
# Coerce Py2k to act more like Py3k
from __future__ import (absolute_import, division, print_function, unicode_literals)
from builtins import (
ascii, bytes, chr, dict, filter, hex, input, int, isinstance, list, map,
next, object, oct, open, pow, range, round, str, super, zip,
)
```

The "absolute_import" from that will solve the import differences gdp currently has. I'd recommend just grabbing all of it. Then I find that you can just write py3k code and things just work for both.

Back