Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Strange error, possibly related to var

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.

Strange error, possibly related to var

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.

EDIT: adding another var('x,y') after the print does not help.

Strange error, possibly related to var

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.

EDIT: adding another var('x,y') after the print does not help.