From c9f410a3416ad9b3ea8cd770523c3693bd28c433 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Tue, 4 Feb 2020 17:37:09 +0100 Subject: [PATCH] Add Tuples of variable size to the cheat sheet --- docs/source/cheat_sheet_py3.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/source/cheat_sheet_py3.rst b/docs/source/cheat_sheet_py3.rst index 7eacba404fe0..002ed6241180 100644 --- a/docs/source/cheat_sheet_py3.rst +++ b/docs/source/cheat_sheet_py3.rst @@ -65,8 +65,11 @@ Built-in types # For mappings, we need the types of both keys and values x: Dict[str, float] = {'field': 2.0} - # For tuples, we specify the types of all the elements + # For tuples of fixed size, we specify the types of all the elements x: Tuple[int, str, float] = (3, "yes", 7.5) + + # For tuples of variable size, we use one type and ellipsis + x: Tuple[int, ...] = (1, 2, 3) # Use Optional[] for values that could be None x: Optional[str] = some_function()