Issue
The function works in python2:
def setCellValue(self, (x, y), value):
self.map[x][y] = value
But when I'm trying in python3 it shows invalid syntax:
def setCellValue(self, (x, y), value):
^
SyntaxError: invalid syntax
Is it the bracket problem? How can I fix this in py3?
Solution
Yes, tuple unpacking was removed in python3. According to PEP 3113:
The example function at the beginning of this PEP could easily be rewritten as:
def fxn(a, b_c, d): b, c = b_c pass
and in no way lose functionality.
It's existence served only to complicate the grammar and bytecode generation, so it was removed.
Answered By - cs95
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.