
July 19, 2009
3:28 a.m.
On Sun, 19 Jul 2009 06:54:39 am Michael Lenzen wrote:
I don't understand how this code becomes unreadable.
hand = collection(ordered=False, unique=False) for i in range(5): hand.add(deck.pop_card())
Do you expect that code to work if the caller had used "mutable=False" in the call to collection()?
for card in cards: if hand.count(card) == 2: print('You have a pair.')
Why would a class with unique=True have a count() method? -- Steven D'Aprano