If you are trying to compare two people, the comparison itself isn't also a person.
Python classes have special methods you can overide that allow inbuilt python equalities to work.
For example:
class Person():
__init__(self, name="Sinead OConnor", etc...):
# boiler plate goes here
self.name = name
__eq__(self, anotherPerson):
return False # Perople are wonderful and unique and have no equal
__cmp__(self,anotherPerson):
return anotherPerson == "You" # Nothing compares too you!
These will then allow you to do things like:
> a = Person(a)
> b = Person(b)
> a == b
False
Obviouusly, how to compare people is difficult and application specific, but once the logic is in it makes sence.
For your work, where you need to compare to people in the abstract "are they a good fit" sence, `cmp won't work as thats just is one thing greater than, less than or equal to another.
In those cases, you can do the following
class Person():
delta = 100 # How close do 2 things need to be to be a good match
__init__(self, name="Sinead OConnor", etc...):
# boiler plate goes here
self.name = name
def loveOfPowerBallads(self,myRank):
if 0<myRank<100:
raise OutOfRange # Or whatever
self.rankPowerBallads = myRank
def isGoodMatch(self,otherPerson):
return (self.rankPowerBallads - other.rankPowerBallads) ^ 2 < Person.delta
Then:
> ls = Person("legoStormtrooper")
> ls.loveOfPowerBallads(95)
> lp = Person("Lame Person")
> ls.loveOfPowerBallads(30)
> ls.isGoodMatch(lp)
False
Edit: Making it more specific for you (although the principle is the same):
class Person:
def __init__(self, name):
self.name=name
self.sun = (randomDecimal(1, 12), randomDecimal(0, 30))
self.moon = (randomDecimal(1, 12), randomDecimal(0, 30))
# etc...
def compare(self,other):
overall = 0
if abs(self.sun - other.sun) in [2,4,8,10]:
overall += 4
elif abs(self.sun - other.sun) in [3,9]:
overall -= 6
elif abs(self.sun - other.sun) == 6:
overall += 3
else:
overall += 0
return overall