
Steven D'Aprano schrieb:
On Wed, 28 Oct 2009 04:47:59 am Raymond Hettinger wrote:
A dict.get() can be meaningfully used in a loop (because the key can vary). A set.get() returns the same value over and over again (because there is no key).
I don't believe anyone has requested those semantics. The suggested semantics for set.get() with no arguments, as I understand them, are:
(1) it will only fail if the set is empty;
(2) it should be efficient;
(3) if you call it repeatedly on a set without modifying the set, you will cycle through each element in turn in some unspecified arbitrary order.
I don't like this. It gives a set object a hidden state, something that AFAICS no other builtin has. Iterating over an iterable is what iterators are for.
Georg