Ask Your Question

Revision history [back]

Sage cannot find user defined contains method

What am I doing wrong?

class Circle:
    def __init__(self, m, r):
        self.xm = m[0]
        self.ym = m[1]
        self.r = r

    def __str__(self):
        return "Circle"

    def __contains__(self, point):
        return True

In Sage:

sage: c = Circle((0,0),1) 
sage: print (0,0) in c
TypeError: argument of type 'instance' is not iterable
click to hide/show revision 2
retagged

Sage cannot find user defined contains method

What am I doing wrong?

class Circle:
    def __init__(self, m, r):
        self.xm = m[0]
        self.ym = m[1]
        self.r = r

    def __str__(self):
        return "Circle"

    def __contains__(self, point):
        return True

In Sage:

sage: c = Circle((0,0),1) 
sage: print (0,0) in c
TypeError: argument of type 'instance' is not iterable