calthoff/goselftaught

43: War.py Question about Scope and Understanding Return

Opened this issue · 1 comments

Could someone please breakdown how magic methods lt and gt work, how they are called and how return is finally implemented? I’m trying to gain a better grasp and right now I see it as, if all these things don’t work then return False.

See code here:

def __lt__(self, c2):

@calthoff

I feel the two magic methods have something to do with the code. here in the Game Class that follows, however I am just unsure where or how the gt and lt magic methods are work or where they are called:

self.draw(p1n, p1c, p2n, p2c) if p1c > p2c: self.p1.wins += 1 self.wins(self.p1.name)