Skip to main content

Implementation of the deck collection type.

Project description

Deck

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()
>>> d.deal()
Card(<Suit.Diamonds: '♦'>, <Value.Two: 2>)
>>> d.deal()
Card(<Suit.Diamonds: '♦'>, <Value.Three: 3>)
>>> d.deal()
Card(<Suit.Hearts: '♥'>, <Value.Ten: 10>)
>>> d.deal()
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 = [d.deal() for _ in range(5)]
>>> p2 = [d.deal() 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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file deck-3.0.0.tar.gz.

File metadata

  • Download URL: deck-3.0.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for deck-3.0.0.tar.gz
Algorithm Hash digest
SHA256 701a74566951ca3dd7a6c0bc6b45a348060cfae7e2093a1bf814417632daa896
MD5 a6f60b23b4cc9c4d19c3589ca2139706
BLAKE2b-256 c197eb3d672139350610366fe274782e64238c93d2b16fc70519aa04e0591f1b

See more details on using hashes here.

File details

Details for the file deck-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: deck-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.27.1

File hashes

Hashes for deck-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6df7a9743d55ebd1fc21fed77a1b8a52c274ed90cb40232ec61352ce7bbe5010
MD5 ac99cbf70c54789b639110149e9d6a36
BLAKE2b-256 1fa1abe4fd1d3c88a01bce4afcb59eaf481b815b5400d1763653eb47afef6f51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page