[issue14893] Tutorial: Add function annotation example to function tutorial
Changes by Zachary Ware zachary.w...@gmail.com: -- versions: +Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Roundup Robot added the comment: New changeset 2bf99322218f by Andrew Svetlov in branch '3.2': Issue #14893: Add function annotation example to function tutorial. http://hg.python.org/cpython/rev/2bf99322218f New changeset 45167091b5f9 by Andrew Svetlov in branch '3.3': Merge issue #14893: Add function annotation example to function tutorial. http://hg.python.org/cpython/rev/45167091b5f9 New changeset 63b495ff366b by Andrew Svetlov in branch 'default': Merge issue #14893: Add function annotation example to function tutorial. http://hg.python.org/cpython/rev/63b495ff366b -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Andrew Svetlov added the comment: Fixed. Thanks, Zachary. -- nosy: +asvetlov resolution: - fixed stage: patch review - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Zachary Ware added the comment: Thank you Éric for the approval, and Andrew for the commit! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Éric Araujo mer...@netwok.org added the comment: LGTM, will commit. -- assignee: docs@python - eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Zachary Ware zachary.w...@gmail.com added the comment: Thanks for the review :). Replied and here's the updated patch. -- Added file: http://bugs.python.org/file25708/annotations_tutorial.v2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Éric Araujo mer...@netwok.org added the comment: Thanks for the patch. I made some comments on the code review tool, which should have sent you a mail. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
New submission from Zachary Ware zachary.w...@gmail.com: A couple months ago, I had never before heard of function annotations and came across a function that had them (I don't remember where or what it was). I spent a fair bit of time searching fruitlessly to figure out what the heck that - in the function definition meant. Then finally, a week or two ago, I came across a mention of pep 3107 and function annotations, and figured out what it was that confused me so thoroughly. In an effort to save others from the same confusion, I've put together a small subsection to add to the tutorial about function definition. The text I'm proposing to add is as follows: :ref:`Function annotations function` are completely optional, arbitrary metadata information about user-defined functions. Python itself currently does not use annotations for anything, so this section is just for familiarity with the syntax. Annotations are stored in the :attr:`__annotations__` attribute of the function as a dictionary and have no effect on any other part of the function. Parameter annotations are defined by a colon after the parameter name, followed by an expression evaluating to the value of the annotation. Return annotations are defined by a literal ``-``, followed by an expression, between the parameter list and the colon denoting the end of the :keyword:`def` statement. The following example has a positional argument, a keyword argument, and the return value annotated with nonsense:: def f(ham: 42, eggs: int = 'spam') - Nothing to see here: ... print(Annotations:, f.__annotations__) # print the function's own annotations ... print(Arguments:, ham, eggs) ... f('wonderful') Annotations: {'eggs': class 'int', 'return': 'Nothing to see here', 'ham': 42} Arguments: wonderful spam I'd also like to see a link for - in the index, either to this note or to the relevant paragraph of compound_stmts.rst or both. The attached patch attempts to add such a link to this section, but I'm not certain that it's done properly. Thanks :) -- assignee: docs@python components: Documentation files: annotations_tutorial.patch keywords: patch messages: 161451 nosy: docs@python, zach.ware priority: normal severity: normal status: open title: Tutorial: Add function annotation example to function tutorial type: enhancement versions: Python 3.2, Python 3.3 Added file: http://bugs.python.org/file25684/annotations_tutorial.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Raymond Hettinger raymond.hettin...@gmail.com added the comment: This looks like a reasonable addition to the tutorial :-) -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14893] Tutorial: Add function annotation example to function tutorial
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +eric.araujo, ezio.melotti stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14893 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com