2

I have a piece of code that looks completely fine,

def _change_id(self, model, path, it,(old_id, new_id)):

But whenever I try to run it in my terminal python returns, "SyntaxError: invalid syntax"

sn0w
  • 21
  • 1
  • I tested in Python 2.7.x shell and it worked. Python 3.x does throw an error. For those that see this question, the error indicator points at `(old_id, new_id)` parameter – Trés DuBiel Jan 18 '16 at 21:33

3 Answers3

4

The use of the tuple parameter was removed in python 3.0. This caused more issues than it was worth. You can rewrite it this way:

def fun(p1, b_c, p2):
    b, c = b_c

the parameter b_c was a tuple:

fun(1, (1, 2), 3)
Ethan Furman
  • 63,992
  • 20
  • 159
  • 237
Luan Oliveira
  • 338
  • 1
  • 10
1

Its called Removal of Tuple Parameter Unpacking (only in python3)

see http://legacy.python.org/dev/peps/pep-3113/

Yoav Glazner
  • 7,936
  • 1
  • 19
  • 36
0

Apparently, tupple parameter unpacking was removed in python 3 as per this link here

Edit: @Yoav and @jonrsharpe beat me to it

Trés DuBiel
  • 540
  • 3
  • 16