[gdal-dev] print throw a SyntaxError with Python 2.6

Gilles Bassière gbassiere at gmail.com
Fri Mar 19 09:47:16 EDT 2010


Hi,

I got the following error with gdal_retile.py (fresh GDAL 1.7.1 install
on an Ubuntu jaunty box):

>   File "/home/gba/Apps/usr/bin/gdal_retile.py", line 273
>     print("Building internal Index for %d tile(s) ..." % len(inputTiles), end=' ')
>                                                                              ^
> SyntaxError: invalid syntax

My Python verstion is:

> $ python -V
> Python 2.6.2

I think the problem comes from the use of print as a function instead of
a statement. Indeed, as long as print is considered a statement, the
parenthesis delimits a tuple (not function arguments) and a tuple
doesn't accept named arguments, hence the SyntaxError.

I've been able to work around this by adding:
> from __future__ import print_function
at the beginning of the script, as suggested in
http://docs.python.org/release/2.6.2/library/functions.html#print.

Regards
-- 
Gilles Bassière - Web/GIS software engineer
http://gbassiere.free.fr/


More information about the gdal-dev mailing list