Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.