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
contextlib doc bug #73320
Comments
Link: https://docs.python.org/3/library/contextlib.html#contextlib.ContextDecorator "from contextlib import ContextDecorator class mycontext(ContextBaseClass, ContextDecorator):" "ContextBaseClass" is referenced but its no where to be found in source. |
ContextBaseClass is meant to represent a user-defined class that is a parent of mycontext. |
Going a bit OT, in the contextlib doc there are two examples that have both normal code and shell code in the same code block. In this way we loose the prompt syntax highlight, and the code block can also confuse the reader. In the patch attached the two examples are executed entirely in the shell, and both are under doctest. |
@SilentGhost If this is the case maybe "ContextBaseClass" should be changed to "UserDefinedContextClass" (or something...) having "Base" in the class name was confusing, since module "io" has IOBase class that refer to its "base class" figured it was the same concept for contextlib as well. Also it would be nice if example was improved a bit. Another Idea:
def ContextBase: def __enter__(self):
return self
def __exit__(self, *errors):
pass This is something anyone can use to extend their class to support context manager? I actually have a class like this i have used many times in my projects! Its simple yet useful. |
typo: |
I am going to vote for "not a bug" here. From the context is it understood that the
The idea here is the illustrate the Mixin possibility with a Base class and not to provide a full example with Base class code as well. @marco, also not a good ticket add more doc strings to this module.rst. If the docs of those can be improved, they can done separately, concentrating on all the possible improvements. |
I would think that the idea of simply adding some reference to |
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: