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

The moveToPoint method occurs three times in the file, with identical
signatures. The other two are not showing up as errors, though since
they occur later in the file, that may not be indicative.

I don't see anything erroneous in this line. The syntax error often
comes from the previous line, but I've moved this method around and
it has always failed on this line and no other, regardless of what
went before.

I'm new to Py3, so maybe there's some obvious thing I'm not seeing
here. Does anyone have any suggestions?

--
rzed

Search Discussions

  • Steve+Comp Lang Python at Jun 26, 2011 at 2:51 pm

    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
  • Rzed at Jun 26, 2011 at 3:28 pm
    steve+comp.lang.python at pearwood.info wrote in
    news:4e074768$0$29982$c3e8da3$5496439d at 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
  • Chris Angelico at Jun 26, 2011 at 3:31 pm

    On Mon, Jun 27, 2011 at 1:28 AM, rzed wrote:
    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....
    Sure, but you don't _have_ to look at the diff. Just run it through
    2to3 and see how it runs. Never know, it might work direct out of the
    box!

    ChrisA
  • Jerry Hill at Jun 26, 2011 at 4:50 pm

    On Sun, Jun 26, 2011 at 11:31 AM, Chris Angelico wrote:
    Sure, but you don't _have_ to look at the diff. Just run it through
    2to3 and see how it runs. Never know, it might work direct out of the
    box!
    This has been my experience, by the way. I've used a few small pure
    python libraries written for python 2.x that don't have 3.x versions,
    and they've all worked just fine with just a quick run through the
    2to3 process. I can't speak for larger libraries, or ones with lots
    of compiled code, but my experience with 2to3 has been great.

    --
    Jerry
  • Noah Hall at Jun 26, 2011 at 3:32 pm

    On Sun, Jun 26, 2011 at 4:28 PM, rzed wrote:
    steve+comp.lang.python at pearwood.info wrote in
    news:4e074768$0$29982$c3e8da3$5496439d at 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....
    It means delete every line with a '-' and replace them with those next
    to the '+'
    Of course, if you read the doc, it'll give you lots of different
    options, including writing to the file, so all you need to do is
    change the variable names.
  • Terry Reedy at Jun 26, 2011 at 5:31 pm

    On 6/26/2011 11:28 AM, rzed wrote:
    steve+comp.lang.python at pearwood.info wrote in
    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.
    When you are done, I hope you feed results back to author as to how to
    make code run under Py3 without change (the explicit unpacking needed
    for Py3 works in Py2 also) or without further change after 2to3. Then
    encourage author to advertise fact and add Py3 classifier if listed in PyPI.

    --
    Terry Jan Reedy
  • Peter Otten at Jun 26, 2011 at 2:59 pm

    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>

    The moveToPoint method occurs three times in the file, with identical
    signatures. The other two are not showing up as errors, though since
    they occur later in the file, that may not be indicative.

    I don't see anything erroneous in this line. The syntax error often
    comes from the previous line, but I've moved this method around and
    it has always failed on this line and no other, regardless of what
    went before.

    I'm new to Py3, so maybe there's some obvious thing I'm not seeing
    here. Does anyone have any suggestions?
    Quoting

    http://docs.python.org/dev/py3k/whatsnew/3.0.html#removed-syntax

    """
    You can no longer write def foo(a, (b, c)): .... Use def foo(a, b_c): b, c b_c instead.
    """

    If there isn't a Python 3 version of PySVG you can try to run it through

    http://docs.python.org/dev/py3k/library/2to3.html#to3-reference

    to make the easy changes.
  • Noah Hall at Jun 26, 2011 at 3:10 pm

    On Sun, Jun 26, 2011 at 2:04 PM, 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>

    The moveToPoint method occurs three times in the file, with identical
    signatures. The other two are not showing up as errors, though since
    they occur later in the file, that may not be indicative.

    I don't see anything erroneous in this line. The syntax error often
    comes from the previous line, but I've moved this method around and
    it has always failed on this line and no other, regardless of what
    went before.

    I'm new to Py3, so maybe there's some obvious thing I'm not seeing
    here. Does anyone have any suggestions?
    Did you run it through 2to3? When I run
    def a(b, (c,d)):
    pass
    through 2to3, it tells me what I need to change.

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

    (which is what Steven said)

    If you haven't used 2to3, I suggest you use it.

    HTH.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 26, '11 at 1:04p
activeJun 26, '11 at 5:31p
posts9
users7
websitepython.org

People

Translate

site design / logo © 2023 Grokbase