Strange use of Lambda arrow

Chris Angelico rosuav at gmail.com
Fri Jun 5 12:40:08 EDT 2020


On Sat, Jun 6, 2020 at 2:36 AM Agnese Camellini
<agnese.camellini at gmail.com> wrote:
>
> Hello to everyone, lately i building up an open source project, with some
> collaborator, but one of them cannot contribute any more. He is a solution
> architect so he is very skilled (much more than me!). I am now analysing
> his code to finish the job but i don't get this use of the lambda arrow,
> it's like he is deplaring the returned tipe in the function signature (as
> you would do in Java). I have never seen something like this in python..
>
> Can someone please explain to me this usage (the part regarding the
> question is highlighted in yellow):
>
>     @classmethod
>     def extract_document_data(cls, file_path : str) -> DocumentData:

I don't know what you highlighted in yellow, as that part didn't come
through. But in Python, that arrow has nothing to do with lambda
functions; it is exactly as you describe, annotating a function with
the type of its return value.

ChrisA


More information about the Python-list mailing list