Message311612
https://docs.python.org/3.5/tutorial/controlflow.html#function-annotations
The end of the first paragraph states, "The following example has a positional argument, a keyword argument, and the return value annotated:"
However, the only function call is f('spam') which has a single positional argument.
I believe the author was referencing the output of print("Annotations:", f.__annotations__) which was:
Annotations: {'ham': <class 'str'>, 'return': <class 'str'>, 'eggs': <class 'str'>}
and then confused that with 4.7.2. Keyword Arguments (https://docs.python.org/3.5/tutorial/controlflow.html#keyword-arguments) where it points out that keyword arguments follow positional arguments. However, the difference between identifying a positional argument vs keyword argument is done at the function CALL, not the function DEFINITION since any argument can be both positional or keyword, depending on how it is referenced.
Moreover, the last sentence in 4.7.2. Keyword Arguments, points out that the order of unsorted sequences is undefined, which would then explain why 'return' appears in the middle here instead of at the end. |
|
Date |
User |
Action |
Args |
2018-02-04 17:57:24 | John Hossbach | set | recipients:
+ John Hossbach, docs@python |
2018-02-04 17:57:24 | John Hossbach | set | messageid: <1517767044.74.0.467229070634.issue32766@psf.upfronthosting.co.za> |
2018-02-04 17:57:24 | John Hossbach | link | issue32766 messages |
2018-02-04 17:57:24 | John Hossbach | create | |
|