[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-20 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- resolution: -> rejected status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing

[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-20 Thread Terry J. Reedy
Terry J. Reedy added the comment: Raymond, I pretty much agree with your points and would be happy either with rejection or one simple sentence. This idiom really belongs in a hypothetical how-to, such as 'Python iterators and generators'. The real use case for it=iter() followed by next(it)

[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-20 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't think it is a good idea to expand to the pop/popitem docs this way. The text is not about what pop/popitem does, it is about what another hypothetical method might do. The text would be a distractor from the focused description of what pop/popite

[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-18 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: docs@python -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-17 Thread Nadeem Vawda
Nadeem Vawda added the comment: > "popitem() > Remove and return an arbitrary (key, value) pair from the dictionary. Raises > KeyError if the dict is empty. Use next(iter(d)) to return an arbitrary pair > without removing it." Actually, next(iter(d)) on a dict returns an arbitrary *key*; if

[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-16 Thread Éric Araujo
Éric Araujo added the comment: > Use next(iter(s)) to return an arbitrary element I would suggest s/return/get/ IIUC calling this twice in a row will get the same element; should the doc mention that? -- nosy: +eric.araujo ___ Python tracker

[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-16 Thread Ned Deily
Changes by Ned Deily : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue14836] Add next(iter(o)) to set.pop, dict.popitem entries.

2012-05-16 Thread Terry J. Reedy
New submission from Terry J. Reedy : There have been several requests for a set.get() (no args) or set.pick() method to get an item without deleting it as .pop() does. Probably the best answer is to use the simple generic composition next(iter(s)). The counter response is that it is hardly obv