LoginSignup
2
0

More than 1 year has passed since last update.

Pythonの分割代入での型アノテーション

Last updated at Posted at 2021-03-04

型アノテーションは単体に対して使えない。
下記のように事前に定義して書くしかなさそう。
参考:PEP526

動く

a: int
b: str
a, b = 1, "hello"

from typing import Tuple
c: Tuple[int,str] =1, "hello"

これらはできない

(a,b) :Tuple[int,str] = 1, "hello"
a, b :int, str = 1, "hello"
2
0
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
2
0