Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8464

Re: Python 3 syntax error question

Newsgroups comp.lang.python
Subject Re: Python 3 syntax error question
From rzed <rzantow@gmail.com>
References <Xns9F105B30356CArzantowgmailcom@74.209.131.13> <4e074768$0$29982$c3e8da3$5496439d@news.astraweb.com>
Message-ID <Xns9F1073B21B96Frzantowgmailcom@74.209.131.13> (permalink)
Organization UseNetServer.com
Date 2011-06-26 15:28 +0000

Show all headers | View raw


steve+comp.lang.python@pearwood.info wrote in
news:4e074768$0$29982$c3e8da3$5496439d@news.astraweb.com: 

> 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? 
> 
> 

Thank you all for your responses. Yes, I am aware of the version 
difference, but not of all the implications of that. I will run this 
through 2to3, but even without doing that, there are only about four 
syntax errors, and the others were obvious and easily corrected. 

There does not seem to be a Py3 version of this package. I was hoping 
to try it to see what broke. Well, I found out at least part of that, 
didn't I?

I was not aware of the removal of tuple-unpacking. I expect there was 
some extensive conversation about that. 

As to 2to3, I have to say that:

-def a(b, (c,d)):
+def a(b, xxx_todo_changeme):
+    (c,d) = xxx_todo_changeme

... is not terribly revealing if one is unaware of what about it 
needs changing. I know, I know: RTFM....

-- 
rzed

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Python 3 syntax error question rzed <rzantow@gmail.com> - 2011-06-26 13:04 +0000
  Re: Python 3 syntax error question steve+comp.lang.python@pearwood.info - 2011-06-27 00:51 +1000
    Re: Python 3 syntax error question rzed <rzantow@gmail.com> - 2011-06-26 15:28 +0000
      Re: Python 3 syntax error question Chris Angelico <rosuav@gmail.com> - 2011-06-27 01:31 +1000
      Re: Python 3 syntax error question Noah Hall <enalicho@gmail.com> - 2011-06-26 16:32 +0100
      Re: Python 3 syntax error question Jerry Hill <malaclypse2@gmail.com> - 2011-06-26 12:50 -0400
      Re: Python 3 syntax error question Terry Reedy <tjreedy@udel.edu> - 2011-06-26 13:31 -0400
  Re: Python 3 syntax error question Peter Otten <__peter__@web.de> - 2011-06-26 16:59 +0200
  Re: Python 3 syntax error question Noah Hall <enalicho@gmail.com> - 2011-06-26 16:10 +0100

csiph-web