Hi Everyone

I'm just starting to learn Python and want to define a class that represents a 
set with a binary operation.  In a Mathematica package I co-wrote for abstract 
algebra we used the term "groupoid" and I know that this isn't the conventional 
definition, but I'm using it below.  I've read how to define a class and I 
thought that this would work for me, as a start;

class GroupoidEAAM():
    """EAAM sense of Groupoid"""
    def __init__(self,elements,fun):
        self.domain=elements
        self.operation=fun
    def display(self):
        displaystring='['
        displaystring+=str(self.domain())
        displaystring+=','
        displaystring+=str(self.operation())
        displaystring+=']'
        return displaystring

When I then evaluate this:

z=GroupoidEAAM([0,1],lambda x,y:(x+y).mod(2))

I get a value for z of <__main__.GroupoidEAAM instance at 0x4cd92d8>, which 
look good, I think.  But then the following expressions all fail:

z.domain()

z.operation()

z.display()

I must be missing something.  Any help?

Ken Levasseur
UMass Lowell

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to