Last active
December 24, 2022 20:04
-
-
Save sloria/5895768 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book: | |
... | |
def __lt__(self, other): | |
return (self.author, self.title) < (other.author, other.title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about this to reduce duplication (makes sense if there are many variables)