Ask Your Question

Revision history [back]

Sage's preparser (*) turns ^ into the exponentiation symbol (**), in order to follow standard math notations:

sage: preparse("a=(a << 8) ^ (L[i])")
'a=(a << Integer(8)) ** (L[i])'

To enforce the original (Python) xor behavior, use ^^ instead of ^:

for i in range(3):
    a=(a << 8) ^^ (L[i])

(*) see the answer to this question.