There is an arrow after the python function name. What does this do?
大家讲道理
大家讲道理 2017-05-18 11:00:48
0
6
952
async def fetch(self, url: str, keys: object, repeat: int) -> (int, object):
    dosomething()
    return None  
    

I found such a statement when I was looking at other people's programs. I checked many places but couldn't find any explanation about "->".
The most similar ones found are arrow functions, but they look different.

What symbol is this? Or where should I check?

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(6)
世界只因有你

Function annotations ?
"Python 3 provides syntax to attach metadata to the parameters of a function declaration
and its return value."

某草草

Stackoverflow has it.
What does -> mean in Python function definitions?

Python 3 extends the feature by allowing you to attach metadata to functions describing their parameters and return values.

Simply put -> It is to tell the user the specific parameters and parameter types.

For details, please see: PEP3107
https://www.python.org/dev/pe...

小葫芦

Just prompt the function’s input parameters and return value数据类型

Easy for programmers to read code.

左手右手慢动作

http://python3-cookbook.readt...

The python cookbook has a detailed description. It is recommended to read this book when you have time. It is still very helpful.

巴扎黑

This is it. . . Prompt for return value type?

phpcn_u1582

This is a type hint that has been officially included since python3.5. It marks the type of variables. For IDEs supported by pycharm, it can provide more accurate code hints and variable inspections.

For specific usage, please see https://docs.python.org/3/lib...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!