Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

43: War.py Question about Scope and Understanding Return #4

Open
cy-lon opened this issue Mar 15, 2024 · 1 comment
Open

43: War.py Question about Scope and Understanding Return #4

cy-lon opened this issue Mar 15, 2024 · 1 comment

Comments

@cy-lon
Copy link

cy-lon commented Mar 15, 2024

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

@cy-lon
Copy link
Author

cy-lon commented Mar 15, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant