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
Sent from my iPhone
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/D6LHXDXPN6K27KV6MZBLG66ZSGCNDRG7/
Code of Conduct: http://python.org/psf/codeofconduct/