from cards import Card, Hand, Deck def make_suit(suit): '''Function for creating a dictionary for a given suit from strings of the form: 'suitface' to the Card object of that suit and that face. ''' faces = ['2','3','4','5','6','7','8','9','10','J','Q','K','A'] cards_in_suit = {} for f in faces: cards_in_suit[suit + f] = Card(f, suit) return cards_in_suit hearts = make_suit('H') diamonds = make_suit('D') spades = make_suit('S') clubs = make_suit('C') # Make a list of all cards full_card_list = hearts.values() + diamonds.values() + spades.values() + clubs.values() deck = Deck(full_card_list) print deck, 'Length:', len(deck) deck.shuffle() print deck, 'Length:', len(deck) hand1 = deck.deal(5) hand2 = deck.deal(5) print 'New Length:', len(deck) print 'Hand 1:', hand1 print 'Hand 2:', hand2 if hand1.has_pair(): print "Hand 1 has a pair!" if hand2.has_pair(): print "Hand 2 has a pair!" if hand1.has_flush(): print "Hand 1 has a flush!" if hand2.has_flush(): print "Hand 2 has a flush!"