Skip to main content

PyDealer is a simple to use Python package for “simulating” decks of standard playing cards (also known as a French Deck). PyDealer let’s you easily create Deck instances, each containing a full 52 card deck of playing cards. Each card is a separate Card instance, with a name, value, suit, and abbreviation. There is also the Stack class, which is useful for creating hands, or discard piles, etc. It is the backbone of the PyDealer package, and actually the Deck class is just a subclass of the Stack class.

PyDealer could possibly be used as part of a CLI (command line interface) card-based game, or even a graphical game as well, I suppose. It may also be of interest to beginner Python programmers, since it’s a relatively simple package, which I created as a way to learn Python, packaging, testing, documentation (Sphinx), etc. I even ended up learning how to use Git a bit, which I must say was slightly frustrating at first. This package has taught me a lot, and maybe someone else can benefit from it as well. Or maybe not. Either way, here it is.

The PyDealer package can be found at the Python Package Index, and should be downloaded from there, and, ideally, installed with pip.

Note to Developers

If you want to work on this project, please make sure you are working on the latest version of the dev branch, and make your pull requests to that branch. Thanks.

Documentation

Full documentation for PyDealer can be found on readthedocs.org:

http://pydealer.readthedocs.org/en/latest/

Quick Usage Example

Here is a quick example, using IDLE, demonstrating how to construct a new Deck instance, representing a full French Deck of cards, as well as how to shuffle the deck, and deal some cards (7 of them) from it, to a hand. Then we’ll print a listing of the contents of the hand, in a human readable way, with a simple print statement.

>>> import pydealer
>>> deck = pydealer.Deck()
>>> deck.shuffle()
>>> hand = deck.deal(7)
>>> hand.sort()
>>> print hand
2 of Diamonds
5 of Hearts
9 of Hearts
9 of Spades
Jack of Spades
King of Clubs
Ace of Clubs

Install/Update/Uninstall with pip

I recommend downloading and installing pip, if you haven’t already, and using that to install PyDealer, from the Python Package Index.

Enter one of the following commands into your *nix Bash or Windows Command Prompt (after installing pip).

Install

$ pip install pydealer

Update

$ pip install pydealer -U

Uninstall

$ pip uninstall pydealer

Release files for pydealer 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydealer 1.4.0
File Size Uploaded
pydealer-1.4.0.zip 38.8 kB Details

Release files / pydealer-1.4.0.zip

Download URL pydealer-1.4.0.zip
Size 38.8 kB
Tags Source
SHA-256 checksum
How to use checksums
44bc46baef18bf33f884840eda2098c4741e662e9efe95449aed07c553d81dcf
BLAKE2b-256 checksum
How to use checksums
694c308a3350dfbc509cfbf15e305b8cad63debf933e47c3e9f9ca5d497c651c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.4.0 This release

1 release file

1.3.0

1 release file

1.2.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page