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
object doesn't have an __enter__/__exit__ yet docs say it does #97699
Comments
|
This is a misreading of the documentation. The entire page uses "object" to refer to some generic object, e.g. the section on Emulating numeric types uses "object" to refer to something that emulates a numeric value. In this section, "object" refers to any arbitrary object whose type defines the two In hindsight we should have called the base class In this case I suggest we change the documentation to use "instance" instead of "object" for the entire page, not just the context manager section. |
|
Would it be a good idea to also add positional-only markers, to indicate that the names are conventions and don’t necessarily need to match the docs? |
That might require updating a lot of links across the rest of CPython's documentation. |
|
That might require updating a _lot_ of links across the rest of CPython's documentation.
It doesn't have to be done all at once. It could be done incrementally, a page at a time, as people notice or otherwise need to work on a page for something else.
The ambiguity between `object` and object is painful. We're probably stuck with it (unless we want to introduce `Object` as an alias and deprecate the lowercase version) but we can at least improve the docs as and when the pain leads to confusion, which it has here.
|
|
Yes, I agree that it might make the data model documentation less confusing if we referred to dunders as My point is that a lot of links to these methods from other parts of the documentation might be broken if the data model docs were reworked in this way. For example, there are currently six other docs files in the CPython repo that link to the datamodel docs on |
A lot of links from other parts of the internet, too, for example from Stack Overflow. Is there no way to have anchors for both or to redirect the old links? |
I'm not sure. @CAM-Gerlach might know more :) But if we're talking about updating the whole page for the datamodel docs so that all dunders are referred to as |
We can redirect external links by creating a ref target label that matches the old anchor pointing to the relevant object, which is only one line per method. That won't for internal links using |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

jamesbraza commentedOct 1, 2022
Documentation
Here's the current docs in the Python data model on
object.__enter__:And
object.__exit__:However, with Python 3.10.3, we see neither of these methods belong to
object:I think the docs could be:
__enter__and__exit__are not methods onobjectThank you for your consideration!
The text was updated successfully, but these errors were encountered: