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
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
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
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,
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.
(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: