[PYTHON] How to write type hints for variables that are assigned multiple times in one line

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

How to write type hints for variables that are assigned multiple times in one line
How to define multiple variables in a python for statement
python> How to write multiple lines> How to write in mnist_with_summaries.py> It seems that there is no need for line concatenation symbols
How to turn the for statement when there are multiple values for one key in the dictionary
How to write a string when there are multiple lines in python
How to write string concatenation in multiple lines in Python
How to do zero-padding in one line with OpenCV
[Jinja2] Solution to the problem that variables added in the for statement are not inherited
[Python] How to write type annotations for Callable objects treated as variables and arguments
How to embed multiple embeds in one message with Discord.py
How to adapt multiple machine learning libraries in one shot
[Python] How to write an if statement in one sentence.
How to write a test for processing that uses BigQuery
Newton's method for machine learning (from one variable to multiple variables)
How to smartly define objects that are commonly used in View
How to write soberly in pandas
How to convert 0.5 to 1056964608 in one shot
How to scrape pages that are “Access Denied” in Selenium + Headless Chrome
[Introduction to Python] How to delete rows that meet multiple conditions in Pandas.DataFrame
How to access environment variables in Python
How to dynamically define variables in Python
How to write this process in Perl?
How to write Ruby to_s in Python
How to write environment variables that you don't want to put on [GitHub] Python
Tips for those who are wondering how to use is and == in Python
How to write files that you should be careful about in all languages
How to receive command line arguments in Python
How to write regular expression patterns in Linux
How to write a ShellScript Bash for statement
Multiple graphs are displayed in one window (python)
How to write async and await in Vue.js
How to write a named tuple document in 2020
How to handle datetime type in python sqlite3
How to find the correlation for categorical variables
I want to write a triple loop and conditional branch in one line in python