In [1]:
def func(x, y):
return x * y
In [2]:
print(func('abc', 3))
In [3]:
print(func(4, 3))
In [4]:
def func_annotations(x: 'description-x', y: 'description-y') -> 'description-return':
return x * y
In [5]:
print(func_annotations('abc', 3))
In [6]:
print(func_annotations(4, 3))
In [7]:
def func_annotations_default(x: 'description-x', y: 'description-y' = 3) -> 'description-return':
return x * y
In [8]:
print(func_annotations_default('abc'))
In [9]:
print(func_annotations_default(4))
In [10]:
def func_annotations_type(x: str, y: int) -> str:
return x * y
In [11]:
print(func_annotations_type('abc', 3))
In [12]:
print(func_annotations_type(4, 3))
In [13]:
def func_annotations(x: 'description-x', y: 'description-y') -> 'description-return':
return x * y
In [14]:
print(type(func_annotations.__annotations__))
In [15]:
print(func_annotations.__annotations__)
In [16]:
print(func_annotations.__annotations__['x'])