LoginSignup
18
6

More than 3 years have passed since last update.

1行で複数代入する変数の型ヒントの書き方

Last updated at Posted at 2019-11-07

関数の返り値など,タプルを複数の変数に展開して代入する時の型ヒントの書き方がわからなかったのでメモ.
こうするらしい.1行では書けない.

from typing import Tuple


def foo() -> Tuple[int, float]:
    return 1, 1.0


a: int
b: float
a, b = foo()

ちなみにこの構文の名前が不明なのだが, unpacking a tuple とかでググると良さそうです.

18
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
6