class CTest(object):
def __init__(self,arg=None):
var('x,y')
if type(arg) is list:
print [x in ZZ for x in arg]
elif arg in PolynomialRing(ZZ,2,(x,y)):
pass
a=CTest()
Traceback (most recent call last):
...
File "", line 6, in __init__
UnboundLocalError: local variable 'x' referenced before assignment
Replacing var('x,y') with x,y=var('x,y') eliminates the error. So does replacing PolynomialRing(ZZ,2,(x,y)) with [1,2,3]. Or changing the x in [x in ZZ for x in arg] to z.