[issue12941] add random.pop()

2011-09-09 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue12941] add random.pop()

2011-09-09 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- resolution: -> rejected stage: patch review -> committed/rejected status: open -> closed ___ Python tracker ___ __

[issue12941] add random.pop()

2011-09-09 Thread John Feuerstein
John Feuerstein 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 cre

[issue12941] add random.pop()

2011-09-09 Thread Ezio Melotti
Ezio Melotti added the comment: >> Not all the sequences have a .pop() method. > Not all sequences support indexing or item assignment either: All the sequences support indexing and len(), but not assignment (e.g. tuples and strings are sequences, but they are immutable). So talking about seq

[issue12941] add random.pop()

2011-09-09 Thread John Feuerstein
John Feuerstein added the comment: > r.pop(random.randrange(0, len(r))) So seq[random.randrange(0, len(seq))] suddenly makes random.choice(seq) obsolete? There is no functional reasoning here, it's convenience for a common operation. > Not all the sequences have a .pop() method. Not all seq

[issue12941] add random.pop()

2011-09-09 Thread Mark Dickinson
Mark Dickinson added the comment: > is it really worth adding? Probably not. For improvements along these lines, I'd rather see random.choice support sets: >>> random.choice({1, 2}) Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versio

[issue12941] add random.pop()

2011-09-08 Thread Julian Berman
Julian Berman added the comment: Considering this is pretty easily written more or less as r = range(20) r.pop(random.randrange(0, len(r))) is it really worth adding? -- nosy: +Julian ___ Python tracker

[issue12941] add random.pop()

2011-09-08 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti, rhettinger stage: -> patch review versions: +Python 3.3 -Python 3.4 ___ Python tracker ___

[issue12941] add random.pop()

2011-09-08 Thread John Feuerstein
New submission from John Feuerstein : This patch against current hg tip (72314:92842e347d98) adds random.pop(): pop(self, seq) method of Random instance Remove and return a random element from a non-empty sequence. Includes test case. -- components: Library (Lib) files: ran