Note that I didn't know how to write a type hint when expanding and assigning a tuple to multiple variables, such as the return value of a function. It seems to do this. You can't write in one line.
from typing import Tuple
def foo() -> Tuple[int, float]:
return 1, 1.0
a: int
b: float
a, b = foo()
By the way, the name of this syntax is unknown, but it seems good to google it with ʻunpacking a tuple`.
Recommended Posts