-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
Documentation from inspect.getdoc() for non-callable attributes math.e can be misleading. #135316
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
Comments
|
In theory, we could create a separate |
The issue with getdoc() is essentially the same as for help(). Only modules, classes, and functions have individual docstrings. dir(math.e) equals dir(float), with equal |
Admittedly while I've been working on the project that triggered this, I keep forgetting that math.e isn't a function. The explanations given make sense in that context. I do wonder, though, if it would be worth using a function that returns e, or tau, or pi, or whatever other constants, instead of just having the constant. Would there be unnecessary performance impact? I don't know, but in my opinion, it would be helpful to have a useful docstring about these constants. |
Yeah, it would be slower and more importantly, it would break a lot of code. I think a better approach would be to design a way to generally add docstrings to arbitrary objects (such as a global |
Another possibility would be introducing module-level |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug description:
inspect module returns wrong documentation for
math.e
.This should return something to the effect of:
"""
Returns the nearest representable value to the mathematical constant
e
, which has a value of 2.718281..." and is the base of natural logorithms."""
CPython versions tested on:
3.11
Operating systems tested on:
Windows
The text was updated successfully, but these errors were encountered: