On 04Nov2009 09:46, Steven D'Aprano <st...@pearwood.info> wrote:
| On Tue, 3 Nov 2009 09:19:38 am Greg Ewing wrote:
| > Cameron Simpson wrote:
| > > Personally, I'm for the iteration spec in a lot of ways.

For the record, I've since, in mere hours or day, been convinced my
preference was misguided.

I _do_ still feel that a hypothetical .pick() (a name I think better than
.get()) would be "nicer" if it didn't always return the same item. Not
that I've imagined any use case not equally well served by the existing
iterator facility :-(

Greg Ewing:
| > I completely fail to see a use case for this.

Steven D'Aprano:
| Nevertheless, people keep requesting it, so obviously they have a use 
| for it. None of the standard solutions are obvious or easily 
| discoverable, and in my experience the usual solution people come up 
| with is to pop() an element, then add() it back in, but of course 
| that's not just inelegant but it fails on frozensets.

Question: has anyone asked for .pick()/.get() with a use case _not_ well
served by the existing facilities?

Personally, I have found it useful in doco I write to have a section on
"Common Tasks", with recommended/suggested examples of how to do them and
short rationale for the chosen method. It seems to me that if .pick()
is frequently desired and "None of the standard solutions are obvious
or easily discoverable" then they should be _made_ so with documentation.

Comments?
-- 
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Politics, n. Strife of interests masquerading as a contest of principles.
- Ambrose Bierce, _The_Devil's_Dictionary_
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to