Ask Your Question

Revision history [back]

This is intentional, and it's part of the SageMath preparser. One way to get around this is to turn it off:

A = {1, 2, 3}
B = {3, 4, 5}
preparser(False) # turn off preparsing when Sage reads the function definition

def test():
    print("hello")
    C = A ^ B
    return C

preparser(True) # safe to turn it back on now
test()

This is intentional, and it's part of the SageMath preparser. , which automatically converts "^" to "**". One way to get around this is to turn it off:

A = {1, 2, 3}
B = {3, 4, 5}
preparser(False) # turn off preparsing when Sage reads the function definition

def test():
    print("hello")
    C = A ^ B
    return C

preparser(True) # safe to turn it back on now
test()