Replies: 1 comment
-
This is a good place to start a discussion for something like this! Personally I don't feel that changing a comma into an arrow is useful enough to justify totally new syntax, though. I also haven't really felt the need to change the syntax for mapping types; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
(I hope this is the right place to suggest something like this.)
The syntax for "map-type" generics is not very nice:
Callable[[int, str], bool]
,Dict[str, int]
,Mapping[str, int]
,DefaultDict[str, int]
. And there was a PEP to improve the Callable syntax but it was rejected. But maybe we can solve all of these at once by introducing a special map-type generic (maybeGenericMap
) which has its own syntax that visually makes it clearer that it's a map. The steering committee didn't seem to like the use of->
so maybe it could be=>
instead:Callable[[int, str] => bool]
(or, if you aliasCallable
asFn
, thenFn[[int, str] => bool]
),Dict[str => int]
,Mapping[str => int]
,DefaultDict[str => int]
.The selling point is that it's not only useful for Callables but for all the dictionary variants as well.
Beta Was this translation helpful? Give feedback.
All reactions