A simple package containing classes/methods for constructing decks of playing cards (standard 'French deck'). Could be used for a CLI game, or even a graphical game as well.
I saw this project /r/python, and it looks really solid. Got a small recommendation: add __str__, __repr__, __hash__, and __eq__ to the Card class. This will allow me to do this:
I'm a big fan of implementing these 4 methods for base classes like Card because then I can use them in data structures (set, dict, etc.) without having to worry about unexpected behavior. I can also print a card and print card-related errors and get meaningful information.
I saw this project /r/python, and it looks really solid. Got a small recommendation: add
__str__
,__repr__
,__hash__
, and__eq__
to the Card class. This will allow me to do this:I suggest something like this:
I'm a big fan of implementing these 4 methods for base classes like
Card
because then I can use them in data structures (set, dict, etc.) without having to worry about unexpected behavior. I can also print a card and print card-related errors and get meaningful information.