class Person: """ An object representing a person. Contructor must be given their last name and first name (both strings). """ def __init__(self, lname, fname): """ Create a new person object, given their last name and first name (both strings). """ self.lname = lname self.fname = fname def __repr__(self): """ Produce the representation of the object that is used when it's printed as part of a list. """ return "Person(%r, %r)" % (self.lname, self.fname) def __str__(self): """ Produce the representation of the object that's used when it's printed by itself. """ return self.lname + ", " + self.fname def __cmp__(self, other): """ Compare to another person. """ if self.lname != other.lname: return cmp(self.lname, other.lname) else: return cmp(self.fname, other.fname) def lastname(self): """ Return the person's last name. """ return self.lname def firstname(self): """ Return the person's first name. """ return self.fname