Re: [Python-ideas] Using rightarrow "->" for typing annotation of functions

2019-04-25 Thread Stephan Hoyer
On Thu, Apr 25, 2019 at 1:51 PM Ivan Levkivskyi wrote: > TBH, I don't think it is so bad that it requires a new syntax. But I am > not strongly against it either. What I would like to add here is that if we > will go with the replacement: > > Callable[[X, Y], Z] becomes (X, Y) -> Z > > then we

Re: [Python-ideas] Using rightarrow "->" for typing annotation of functions

2019-04-25 Thread Tony Yu
Ivan Levkivskyi wrote: > Callable[[X, Y], Z] becomes (X, Y) -> Z > Union[X, Y] becomes X | Y > Tuple[X, Y] becomes (X, Y) > Optional[X] becomes X? > (Intersection[X, Y] when added becomes X & Y) > I really like this idea, but I could also see this getting a bit confusing because the syntax

Re: [Python-ideas] Using rightarrow "->" for typing annotation of functions

2019-04-25 Thread Greg Ewing
Guido van Rossum wrote: Also, some groups of people would like to see a more concise notation for lambdas, and maybe they'd want to write x = (a, b) -> a + b We probably can't have both, I think we could if we wanted to. In an annotation, -> could be treated as sugar for Callable[], and in

Re: [Python-ideas] Using rightarrow "->" for typing annotation of functions

2019-04-25 Thread Ivan Levkivskyi
TBH, I don't think it is so bad that it requires a new syntax. But I am not strongly against it either. What I would like to add here is that if we will go with the replacement: Callable[[X, Y], Z] becomes (X, Y) -> Z then we should also go with Union[X, Y] becomes X | Y Tuple[X, Y] becomes (X,

Re: [Python-ideas] Using rightarrow "->" for typing annotation of functions

2019-04-24 Thread MRAB
On 2019-04-24 22:42, Guido van Rossum wrote: Thanks for posting. I agree that Callable is ugly (even hideous :-), but when we introduced type annotations in PEP 484, we didn't want to introduce new syntax. The existing syntax (using -> in function headings) was supported since Python 3.0.

[Python-ideas] Using rightarrow "->" for typing annotation of functions

2019-04-24 Thread Vaibhav Karve
(Note: This idea is about a particular static typecheking (typing?) annotation syntax). The idea is that currently the use of the "->" (right arrow) is restricted to only function definition annotation. Can we extent it to declaration of type for functions even outside their definitions? Example: