Python 3 syntax error question

steve+comp.lang.python at pearwood.info steve+comp.lang.python at pearwood.info
Sun Jun 26 10:51:20 EDT 2011


rzed wrote:

> I've tried to install PySVG in a Python 3 setting, and I get a few
> errors on the build. Most are easy to fix, but this one I can't
> explain or fix:
> 
> <error>
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "builders.py", line 12, in <module>
>     from pysvg.shape import *
>   File "C:\Python32\lib\site-packages\pysvg\shape.py", line 91
>     def moveToPoint(self,(x,y)):
>                          ^
> SyntaxError: invalid syntax
> </error>

Function signatures with automatic tuple-unpacking are no longer allowed in
Python3. So functions or methods like this:

def moveToPoint(self,(x,y)):

have to be re-written with the tuple unpacking moved into the body of the
function, e.g. something like this:

def moveToPoint(self, x_y):
    x, y = x_y


Are you aware that you're trying to install a Python2 library under Python3?


-- 
Steven




More information about the Python-list mailing list