[Python-ideas] Proposal for extending the collections module - bags / multisets, ordered sets / unique lists
Steven D'Aprano
steve at pearwood.info
Sun Jul 19 03:28:37 CEST 2009
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
More information about the Python-ideas
mailing list