John Feuerstein <j...@feurix.com> added the comment:

> The test doesn't have to check that seq.pop() is working fine (there are 
> other tests for that) but that it's actually called and that it pops the 
> right element from the input sequence (and not e.g. from a copy of the 
> sequence that might have been created at some point).

I agree, that makes sense.

> One use case I might think of is picking all the elements of a sequence until 
> there are no more left, without risking to pick the same element twice.  The 
> same result can be achieved by shuffling the sequence and iterate over the 
> elements though (that doesn't actually leave you with an empty sequence, but 
> that's probably just a unimportant side-effect).

One problem with shuffling in this use case is that you lose the otherwise 
original order of the remaining elements, so there is no way to return from 
"pop random elements" to "pop elements in order" (without working on a shallow 
copy). However, I would agree that this is rather uncommon.

Feel free to close this as "wont fix", after all it is trivial for the user to 
randomly pop elements out of a sequence himself (see above).

There might be other use cases. If nothing else, there's at least issue 12941 
to reference now.

Thanks!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12941>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to