Update the type alias example in PEP 484 (#118)
This commit is contained in:
parent
1cdddf8b00
commit
68ef9a665b
|
@ -217,8 +217,12 @@ alias::
|
|||
T = TypeVar('T', int, float, complex)
|
||||
Vector = Iterable[Tuple[T, T]]
|
||||
|
||||
def inproduct(v: Vector) -> T:
|
||||
def inproduct(v: Vector[T]) -> T:
|
||||
return sum(x*y for x, y in v)
|
||||
def dilate(v: Vector[T], scale: T) -> Vector[T]:
|
||||
return ((x * scale, y * scale) for x, y in v)
|
||||
vec = [] # type: Vector[float]
|
||||
|
||||
|
||||
This is equivalent to::
|
||||
|
||||
|
@ -228,6 +232,9 @@ This is equivalent to::
|
|||
|
||||
def inproduct(v: Iterable[Tuple[T, T]]) -> T:
|
||||
return sum(x*y for x, y in v)
|
||||
def dilate(v: Iterable[Tuple[T, T]], scale: T) -> Iterable[Tuple[T, T]]:
|
||||
return ((x * scale, y * scale) for x, y in v)
|
||||
vec = [] # type: Iterable[Tuple[float, float]]
|
||||
|
||||
|
||||
Callable
|
||||
|
|
Loading…
Reference in New Issue