What are Function Annotations? Syntactic sugar for adding metadata to function definitions
3
Annotations are just syntactic sugar
4
Adding Typing Information
5
Helping tools (IDE, Editor)
6
Wait a sec!
7
Libraries usually do this
8
Experiment: Runtime checking
9
Runtime checking: how it looks
10
But isinstance is killing duck typing!
11
Another example
12
Implementation of structural interfaces
13
Types + behaviour = predicates
14
More fun with predicates
15
The open function annotated again
16
Unions
17
Function overloading
18
More kinds of types typedefs
19
A different approach to type annotations: rightarrow
20
Using rightarrow
21
Combining different uses of annotations
22
Annotations for language bridges
23
Why annotations are not used? • Not a wide know feature
24
Questions?
Description:
Explore practical applications of function annotations in Python during this 57-minute EuroPython 2013 conference talk. Delve into the concept of function annotations as syntactic sugar for adding metadata to function definitions. Learn how to leverage annotations for adding typing information, enhancing IDE and editor support, and implementing runtime checking. Discover the potential of structural interfaces, predicates, and function overloading using annotations. Examine different approaches to type annotations, including the 'rightarrow' library. Investigate how annotations can be utilized for language bridges and discuss reasons for their limited adoption in the Python community. Gain insights into advanced Python features and techniques to improve code quality and maintainability.