So I’m analyzing this code and I have reason to believe this was coded with python 2.X but I’m using 3.2 and would like to convert it so that it would work.
The first error I encountered was with a function with a syntax
def function((x,y))
Why doesn’t it work in Py3 and what’s the alternative?
As Mr E already said in the comment, this feature was removed in Python 3 with PEP 3113. The alternative is very simple, you just have a single parameter which you unpack manually:
Or you define the function with two parameters, and make users of the function unpack their values themselves:
Btw. it’s a good idea to run Python’s
2to3tool to convert existing Python 2 code to match Python 3’s syntax and library changes.