Skip to main content

Implementation of the deck collection type.

Project description


Code style: black

Deck is an implementation of the deck collection type, commonly confused with collections.deque.

>>> from deck import Deck
>>> d = Deck()
>>> d.shuffle()
Card(<Suit.Diamonds: '♦'>, <Value.Two: 2>)
Card(<Suit.Diamonds: '♦'>, <Value.Three: 3>)
Card(<Suit.Hearts: '♥'>, <Value.Ten: 10>)
Card(<Suit.Diamonds: '♦'>, <Value.Nine: 9>)

Deck supports cheating, if that's how you want to play.

>>> d.deal_from_bottom()
Card(<Suit.Spades: '♠'>, <Value.Five: 5>)

Importing the deck module also globally corrects other typographical errors that may occur in your code.

>>> import deck
>>> from collections import deck
>>> deck
<class 'deck.Deck'>

Taking this module too seriously would be a mistake.

However, if you want to use it to write a Poker game, the get_poker_hand function will help.

>>> from deck import Deck, get_poker_hand
>>> d = Deck(include_jokers=False)
>>> d.shuffle()
>>> p1 = [ for _ in range(5)]
>>> p2 = [ for _ in range(5)]
>>> if get_poker_hand(p1) > get_poker_hand(p2):
...     print("Player 1 wins!")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deck-3.0.0.tar.gz (3.7 kB view hashes)

Uploaded source

Built Distribution

deck-3.0.0-py3-none-any.whl (3.3 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page