Hello,
Today I found myself write a function that returns a tuple of list of list of strings (tuple[list[list[str]], list[list[str]]]). Wouldn’t it easier to read to write it like the following:
([[str]], [[str]])?
Similarly for TypedDict, replace the following..
class Movie(TypedDict):
name: str
year: int
with
{‘name’: str, ‘year’: int}
dict[str, int] will be {str: int}
set[int] will be {int}.
This is similar to the new proposed Callable alternative (i.e., (int, float) -> float) since it mimics the structure of a function.
Also, Annotated[float, “seconds”] can be replaced with something like float #seconds indicating whatever comes after the hashtag is just extra information similar to a normal comment in the code.
Imagine you could replace the following
def func(d: dict[Annotated[str, “product label”], Annotated[list[float], “prices from 2000 to 2015”]])…
With
def func(d: {str # product label: [float] # prices from 2000 to 2015})…
Abdulla