Reputation: 39
Arguments of a Python 3.8 function are defined in particular order: positional-only, mixed, keyword-only.
But __annotations__
define them in a different order: mixed, positional-only, keyword-only.
>>> def func(b: int, a: str, /, c: bool, *, e: float, d: tuple):
... pass
...
>>> func.__annotations__
{'c': 'bool', 'b': 'int', 'a': 'str', 'e': 'float', 'd': 'tuple'}
Is that behavour intentional? Or is it just implementation detail and no specific order is guaranteed at all?
I would expect native order of arguments that matches function definition. That would have made some things a lot easier IMO...
Upvotes: 1
Views: 108