New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation error in inspect module #75134
Comments
The documentation for co_names in the inspect module is: "tuple of names of local variables" Local variable names are however in co_varnames while co_names contains global variable names. This description should read: "tuple of names of global variables" Relevant StackOverflow post here: |
Or maybe: "tuple of names of global variables used in the bytecode" |
co_names contains not only names of global variables. It contains also local names in the class scope, attribute names, names of imported modules, etc. |
Serhiy: What change d'you possibly suggest then? |
Maybe something along the lines of "names other than arguments and function locals", or "names of the symbols used in the code object, other than arguments and function locals"? This is still slightly confusing because in the case of an import the name is present in both mappings, but less so than the outright lie of the current version. Serhiy, is there a way to access the class's code object from Python? Also does that mean varnames is not used by class code objects despite it stating unambiguously that it stores locals? |
Thanks, Alex! ✨ 🍰 ✨ |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: