syntax error python 3.4 tetris game -


def check_block( self, (x, y) ):      """     check if x, y coordinate can have block placed there.     is; if there 'landed' block there or outside     board boundary, return false, otherwise return true.     """     if x < 0 or x >= self.max_x or y < 0 or y >= self.max_y:         return false     elif self.landed.has_key( (x, y) ):         return false     else:         return true 

here there syntax error in def part, (x,y)... how fix it?

seems tuple parameter unpacking removed in python 3.

so code

def foo(x, (y, z)):     print(x, y, z)  foo(1, (2, 3)) 

works in python 2.7

>>> python2 test.py  (1, 2, 3) 

but fails in python 3

>>> python3 test.py    file "test.py", line 2     def foo(x, (y, z)):                ^ syntaxerror: invalid syntax 

you can see -3 option in python 2:

>>> python2 -3 test.py  test.py:2: syntaxwarning: tuple parameter unpacking has been removed in 3.x   def foo(x, (y, z)): (1, 2, 3) 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -