Skip to content

Commit 68ef9a6

Browse files
ilevkivskyigvanrossum
authored andcommitted
Update the type alias example in PEP 484 (#118)
1 parent 1cdddf8 commit 68ef9a6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pep-0484.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,12 @@ alias::
217217
T = TypeVar('T', int, float, complex)
218218
Vector = Iterable[Tuple[T, T]]
219219

220-
def inproduct(v: Vector) -> T:
220+
def inproduct(v: Vector[T]) -> T:
221221
return sum(x*y for x, y in v)
222+
def dilate(v: Vector[T], scale: T) -> Vector[T]:
223+
return ((x * scale, y * scale) for x, y in v)
224+
vec = [] # type: Vector[float]
225+
222226

223227
This is equivalent to::
224228

@@ -228,6 +232,9 @@ This is equivalent to::
228232

229233
def inproduct(v: Iterable[Tuple[T, T]]) -> T:
230234
return sum(x*y for x, y in v)
235+
def dilate(v: Iterable[Tuple[T, T]], scale: T) -> Iterable[Tuple[T, T]]:
236+
return ((x * scale, y * scale) for x, y in v)
237+
vec = [] # type: Iterable[Tuple[float, float]]
231238

232239

233240
Callable

0 commit comments

Comments
 (0)