Code: Select all
def add_ints(x: int, y: int) -> int:
return x + y
< /code>
Ich stoße manchmal auf Probleme, wie man einen gegebenen "Typ" darstellt, und diesmal habe ich eine Funktion, die einen Generator zurückgibt: < /p>
def myfunc(x: [int]) -> "generator that returns ints":
# ^~~~~~~~~~~~~~~~~~~~~~~~~~
return (n for n in x if n % 2 == 0)