def func(x: int, y: int, f: (int, int) -> int) -> int:
        return f(x, y)

print(func(1, 4, (x, y) -> x + y)) #Output: 5
         
I think we can still use the same syntax for both typing.Callable and lambda. 
It would act like Callable if it comes after the “:” in annotations or after 
the “->” in function return annotation. After assignment or using it directly 
as an argument, then it acts like lambda. 

func: (str, str) -> None = (text1, text2) -> print(text1 + text2)
Same syntax, but communicates two different things. I don’t see any problem 
with this.
func: (str, str) -> None = (text1, text2) => print(text1 + text2) is not bad 
either to be honest. 

> On 14 Feb 2021, at 12:23 PM, Paul Sokolovsky <pmis...@gmail.com> wrote:
> 
> I for one can't parse that (didn't have a morning coffee, but suspect
> there's a typo/thinko). Btw, I'm not sure about function values, but
> IMHO, type notation should always use parens for arguments, e.g. "(int)
> -> int".

_______________________________________________
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/FT6E4E2B7QBGAM5PVA3D4JPFVHEP5XRJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to