Function Annotations

Published onesixx on

PEP 3107 – Function Annotations

https://stackoverflow.com/questions/14379753/what-does-mean-in-python-function-definitions

def f(x) -> 123:
    return int(x)

def f(x:float) -> int:
    return x
f.__annotations__

# {'x': float, 'return': int}
Categories: Python Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x