API details.
Card is a class that represents a single card in a deck of cards. For example:
Card(suit=2, rank=11)
Card(suit=2, rank=0)
c = Card(suit=1, rank=3)
assert str(c) == '3 of Diamonds'
c2 = Card(suit=2, rank=11)
assert str(c2) == 'Jack of Hearts'
You can do comparisons of cards, too!
assert c2 > c
assert c2 < c
AssertionError Traceback (most recent call last) in —-> 1 assert c2 < c
AssertionError:
Note: Look at fastcore’s testing utilities for convenience functions that print out helpful error messages by default when there is an error. These convenience functions are an improvement upon using assert. 2
You can show the docs for methods by calling show_doc. show_doc(Card.eq) produces the following documentation:
card1 = Card(suit=1, rank=3)
card2 = Card(suit=1, rank=3)
assert card1 == card2