This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Dutcho
Recipients Dutcho, docs@python
Date 2021-10-16.10:45:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634381128.63.0.689395571563.issue45492@roundup.psfhosted.org>
In-reply-to
Content
The standard library documentation on module inspect starts with an overview of types and attributes. This overview (in all Python versions) states:
    code.co_names: tuple of names of local variables
    code.co_varnames: tuple of names of arguments and local variables
That suggests the argument names are set(code.co_varnames) - set(code.co_names), which is incorrect.

I think the attribute description should be:
    code.co_names: tuple of names of used global and built-in variables

>>> def f(x): a = 1; print(f, a)
>>> assert f.__code__.co_varnames == ('x', 'a')  # argument and local, in that order
>>> assert set(f.__code__.co_names) == set(('f', 'print'))  # global and built-in (don't care order), not local
History
Date User Action Args
2021-10-16 10:45:28Dutchosetrecipients: + Dutcho, docs@python
2021-10-16 10:45:28Dutchosetmessageid: <1634381128.63.0.689395571563.issue45492@roundup.psfhosted.org>
2021-10-16 10:45:28Dutcholinkissue45492 messages
2021-10-16 10:45:28Dutchocreate