[Tutor] What is Tuple in the typing module?
C W
tmrsg11 at gmail.com
Fri Aug 16 19:46:06 EDT 2019
Hi everyone,
What exactly is Tuple in the typing module? What does it do?
This is the definition from its website.
https://docs.python.org/3/library/typing.html
"A type alias is defined by assigning the type to the alias"
I have no idea what that means.
Here's the example from the documentation:
from typing import Dict, Tuple, Sequence
ConnectionOptions = Dict[str, str]Address = Tuple[str, int]Server =
Tuple[Address, ConnectionOptions]
def broadcast_message(message: str, servers: Sequence[Server]) -> None:
...
# The static type checker will treat the previous type signature as#
being exactly equivalent to this one.def broadcast_message(
message: str,
servers: Sequence[Tuple[Tuple[str, int], Dict[str, str]]]) -> None:
...
I think this even more confusing. Can someone explain this in simple words?
I don't have a intense computer science background.
Thanks a lot!
More information about the Tutor
mailing list