-
Notifications
You must be signed in to change notification settings - Fork 21
PyDealer Basics
Alex edited this page Jul 3, 2014
·
3 revisions
Install/Uninstall with PIP
pip install pydealer
pip install pydealer -U
pip uninstall pydealer
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
import pydealer deck = pydealer.Deck() deck.shuffle() i = 25 card = deck[i] print card
Example output:
3 of Spades
You can search using full card names, abbreviations, suits, or values.
import pydealer deck = pydealer.Deck() deck.shuffle() name = "Ace of Spades" i = deck.find(name) card = deck[i] print "deck[%d] = %s" % (i, card)
Example output:
deck[28] = Ace of Spades
import pydealer deck = pydealer.Deck() deck.shuffle() terms = ["AS", "Queen of Hearts", "2"] indices = deck.find_list(terms) for i in indices: card = deck[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
import pydealer deck = Deck() deck.shuffle() name = "Ace of Spades" card = deck.get(name) print card
Example output:
Ace of Spades
import pydealer deck = Deck() deck.shuffle() terms = ["KD", "Queen of Hearts", "2"] cards = deck.get_list(terms) for card in cards: print card
Example output:
King of Diamonds Queen of Hearts 2 of Diamonds 2 of Clubs 2 of Spades 2 of Hearts