Issue 16243: Add example for inspect module doc (original) (raw)

Issue16243

Created on 2012-10-15 23:19 by belopolsky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
inspect-formatargspec-example.patch berker.peksag,2012-10-25 21:44 review
Messages (6)
msg173003 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2012-10-15 23:19
In Python 3.3.0 and 3.2.3: >>> from inspect import * >>> def f(a,b):pass ... >>> formatargspec(getargspec(f)) Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/inspect.py", line 905, in formatargspec spec = formatargandannotation(arg) File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/inspect.py", line 898, in formatargandannotation if arg in annotations: TypeError: unhashable type: 'list' No such error in 2.7.1: >>> formatargspec(getargspec(f)) '((a, b), None, None, None)'
msg173004 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2012-10-15 23:57
It looks like a typo in your code. You should use instead: formatargspec(*getargspec(f)) Or better: formatargspec(*getfullargspec(f)) Try with: def f(a: int, b: float): pass
msg173010 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2012-10-16 02:30
My bad, but I think documentation can be improved by adding an example.
msg173802 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2012-10-25 21:44
Here's a patch that adds an example of using `inspect.formatargspec`.
msg173892 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-26 21:28
New changeset 9d3b616fc702 by Andrew Svetlov in branch '3.3': Issue #16243: add example for inspect.formatargspec http://hg.python.org/cpython/rev/9d3b616fc702 New changeset a0337031a6b7 by Andrew Svetlov in branch 'default': Merge issue #16243: add example for inspect.formatargspec http://hg.python.org/cpython/rev/a0337031a6b7
msg173893 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2012-10-26 21:31
Thanks, Berker. I feel the patch is good enough to close the issue. If anybody want to add some value please reopen.
History
Date User Action Args
2022-04-11 14:57:37 admin set github: 60447
2012-10-26 21:31:00 asvetlov set status: open -> closednosy: + asvetlovmessages: + resolution: fixedstage: resolved
2012-10-26 21:28:59 python-dev set nosy: + python-devmessages: +
2012-10-25 21:44:02 berker.peksag set files: + inspect-formatargspec-example.patchnosy: + berker.peksagmessages: + keywords: + patch
2012-10-19 18:47:00 terry.reedy set title: Regression in inspect module -> Add example for inspect module doc
2012-10-16 02:30:50 belopolsky set assignee: docs@pythontype: behavior -> enhancementcomponents: + Documentation, - Library (Lib)versions: - Python 3.2, Python 3.3nosy: + docs@pythonmessages: +
2012-10-15 23:57:54 vstinner set nosy: + vstinnermessages: +
2012-10-15 23:19:45 belopolsky create