add random.choices for 3.6 (#1329)

This commit is contained in:
Jelle Zijlstra
2017-05-24 14:09:52 -07:00
committed by Guido van Rossum
parent 89f27742ca
commit 6152bad0af

View File

@@ -7,8 +7,9 @@
# ----- random classes -----
import _random
import sys
from typing import (
Any, TypeVar, Sequence, List, Callable, AbstractSet, Union
Any, TypeVar, Sequence, List, Callable, AbstractSet, Union, Optional
)
_T = TypeVar('_T')
@@ -50,6 +51,8 @@ def getrandbits(k: int) -> int: ...
def randrange(start: int, stop: Union[None, int] = ..., step: int = ...) -> int: ...
def randint(a: int, b: int) -> int: ...
def choice(seq: Sequence[_T]) -> _T: ...
if sys.version_info >= (3, 6):
def choices(population: Sequence[_T], weights: Optional[Sequence[float]] = ..., *, cum_weights: Optional[Sequence[float]] = ..., k: int = ...) -> List[_T]: ...
def shuffle(x: List[Any], random: Union[Callable[[], float], None] = ...) -> None: ...
def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def random() -> float: ...