Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Syntax Error on Bit Literal [closed]

Tags:

python

I have inherited this python program and, being sort of a noob with bits and such I can't figure out what the problem is. I am getting a syntax error on the first line of the following function:

def tileKey(self, z, x, y):
    zBits = z & 0xFFL
    #  8bits, 256 levels. normally [0,21]
    xBits = x & 0xFFFFFFFL
    #  28 bits
    yBits = y & 0xFFFFFFFL
    #  28 bits
    key = (zBits << 56) | (xBits << 28) | (yBits << 0)
    #  return the key value integer 720576213915009588
    return key
like image 615
Frank Conry Avatar asked Sep 20 '25 23:09

Frank Conry


1 Answers

If you're using Python 3.x, then you can't use the 'L' suffix anymore as it's no longer required and not part of the syntax:

yBits = y & 0xFFFFFFFL
Original exception was:
  File "<stdin>", line 1
    0xFFL
        ^
SyntaxError: invalid syntax
like image 172
Jon Clements Avatar answered Sep 22 '25 12:09

Jon Clements