Search code examples
pythonpython-3.xpython-2.7syntax-error

Why do parentheses as a python argument cause a syntax error?


When following a python2 tutorial, it often defines functions like this:

def scale(self, (centre_x, centre_y), scale):

which throws a SyntaxError in python3, highlighting the parenthesis in front of "centre_x". I also notice that you cannot use parentheses to group, say like this:

def test(x, (y + 1)):

What am I missing?


Solution

  • This was a supported syntax in Python 2.x but it was removed in Python 3.0.

    See PEP 3113 – Removal of Tuple Parameter Unpacking for detail.