[GRASS-dev] Changes between Python 2 and Python 3 that might need attention in GRASS

Vaclav Petras wenzeslaus at gmail.com
Mon Jan 13 10:28:15 PST 2014


On Mon, Jan 13, 2014 at 11:48 AM, Pietro <peter.zamb at gmail.com> wrote:

> On Mon, Jan 13, 2014 at 4:25 PM, Moritz Lennert
> <mlennert at club.worldonline.be> wrote:
> > Issues I think might need attention (but this is without verification
> within
> > the grass python code):
> >
> > - Print Is A Function
> > - Views And Iterators Instead Of Lists
> > - PEP 0238: An expression like 1/2 returns a float. Use 1//2 to get the
> > truncating behavior.
> > - Text Vs. Data Instead Of Unicode Vs. 8-bit
>
> Perhaps we can insert the following import statement in all the python
> scripts that we want to make compatible with python3
>
> from __future__ import (nested_scopes, generators, division,
> absolute_import, with_statement, print_function, unicode_literals)
>
> so we can start slowly to move from python2 => python3
> what do you think?
>
>
Thanks for the overview and suggestions, Moritz and Pietro. I added the -3
flag to python call somewhere in the makefiles, which checks at least the
basic things [r56821] (it runs when Python files are compiled to bytecode).

The `from __future__ import` is probably a good next step. But I would
start slowly, one reason is the manpower, the other is the lack of tests. I
would say that this can be checked when one is changing and testing the
module anyway (although it should be committed separately), not by one big
change for all modules.

Two questions. Is the `from __future__ import` Pietro provided save for
GRASS minimal Python version (probably 2.6)? And how 2to3 tool can help us?

Vaclav


[r56821] https://trac.osgeo.org/grass/changeset/56821
-3     : warn about Python 3.x incompatibilities that 2to3 cannot trivially
fix

Pietro
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20140113/3c4d31fb/attachment-0001.html>


More information about the grass-dev mailing list