[Python-bugs-list] [ python-Bugs-753602 ] random.sample not properly documented
SourceForge.net
noreply@sourceforge.net
Thu, 12 Jun 2003 17:06:08 -0700
Bugs item #753602, was opened at 2003-06-12 18:18
Message generated for change (Comment added) made by tim_one
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=753602&group_id=5470
Category: Documentation
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Gerrit Holl (gerrit)
>Assigned to: Raymond Hettinger (rhettinger)
Summary: random.sample not properly documented
Initial Comment:
random.sample seems to take a third argument:
38 >>> random.sample(seq, 10, 'bla')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/local/lib/python2.3/random.py", line 247,
in sample
j = int(random() * (n-i))
TypeError: 'str' object is not callable
However, the docs don't mention it.
I will try to patch it tomorrow (need to find out what
it does first ;)
Gerrit.
----------------------------------------------------------------------
>Comment By: Tim Peters (tim_one)
Date: 2003-06-12 20:06
Message:
Logged In: YES
user_id=31435
It's documented correctly. The third argument is
int=int
and is simply a speed trick to avoid the expense of looking up
the builtin name "int" in the function body every time the
function is called. Lots of speed-intensive functions do that,
alas. Since you're calling function with three arguments
that's documented as taking two, your code is in error.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=753602&group_id=5470