A package for constructing decks of playing cards.
Project description
A simple package for constructing a Deck object, of 52 common playing cards. Each card is a separate Card object, with a name, value, suit, and abbreviation. Could possibly be used for a command prompt/console, card-based game, or even a graphical game as well, I suppose.
Install/Uninstall with PIP
Install Latest Version
pip install pydealer
Uninstall
pip uninstall pydealer
Basic Usage
Make a Deck, Deal Some Cards
import pydealer deck = pydealer.Deck() deck.shuffle() hand = deck.deal(7) for card in hand: print card
Example output:
9 of Clubs 5 of Diamonds Ace of Diamonds Jack of Hearts 10 of Diamonds 4 of Clubs 6 of Hearts
Peek at Specific Deck Indice
import pydealer deck = pydealer.Deck() deck.shuffle() i = 25 card = deck.peek(i) print card
Example output:
3 of Spades
Find Specific Card(s) Locations
You can search using full card names, abbreviations, suits, or values.
Single Card
import pydealer deck = pydealer.Deck() deck.shuffle() name = "Ace of Spades" i = deck.find(name) card = deck.peek(i) print "deck[%d] = %s" % (i, card)
Example output:
deck[28] = Ace of Spades
List of Cards
The list can contain full card names, abbreviations, suits, values, or a mixture of any/all of them.
import pydealer deck = pydealer.Deck() deck.shuffle() terms = ["AS", "Queen of Hearts", "2"] indices = deck.find(terms) for i in indices: card = deck.peek(i) print "deck.cards[%d] = %s" % (i, card)
Example output:
deck.cards[16] = 2 of Hearts deck.cards[19] = Queen of Hearts deck.cards[21] = 2 of Spades deck.cards[24] = 2 of Diamonds deck.cards[28] = 2 of Clubs deck.cards[34] = Ace of Spades
Get & Remove Specific Card(s)
import pydealer deck = Deck() deck.shuffle() name = "Ace of Spades" card = deck.get(name) print card print terms = ["KD", "Queen of Hearts", "2"] cards = deck.get(terms) for card in cards: print card
Example output:
Ace of Spades King of Diamonds Queen of Hearts 2 of Diamonds 2 of Clubs 2 of Spades 2 of Hearts
Relevant Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pydealer-1.2.2.zip
(13.1 kB
view hashes)