GeezerVison is showing github.com — Add a tutorial for cmd.Cmd for `emptyline()` and `do_EOF` · Issue #144338 · python/cpython
Add a tutorial for cmd.Cmd for emptyline() and do_EOF #144338DescriptionDocumentation
This is w.r.t the issue #143804
It was pointed out it is not a bug (agreed) but we can improve the documentation of this module
since it is now not very clear that
- One has to over-ride "emptyline" so that the last line is not repeated
- One has to over-ride do_EOF to quit cleanly
A tutorial on this in the documentation would be helpful as right now these are at the level of method level documentation and quite unclear at the usage level.
Linked PRs
Activitysabasiddique1 commented on Jan 30, 2026 I’d like to work on #144338. I can add a short example in cmd docs showing how to override emptyline() and do_EOF() for shells that use default(). Reacted by Anand B Pillai and An Long changed the title [-]Modify documentation of cmd.Cmd to indicate subtle behaviours[/-] [+]Add a tutorial for cmd.Cmd[/+] on Feb 1, 2026picnixz commented on Feb 1, 2026 For this issue I do not want the current documentation to be altered in any way. I only want a HOWTO/Tutorial/cookbook for this module, like we have for logging or Enum so please:
- Do not use AI for generating your content. If I ever see an AI-generated PR I will close the PR without reviewing it.
- Take inspiration from our existing guides. We have a page that contains all existing tutorials I think so you should take a look at it.
Reacted by Tan Long and Saba Siddique Divyanshudevtalla commented on Feb 3, 2026 Divyanshudevtalla commented on Feb 3, 2026 picnixz commented on Feb 3, 2026 @Divyanshudevtalla I clearly said what needs to be done. If you used an LLM for your answer but did not review its content, stop it. I am tired of low-quality comments that do not add anything valuable to the discussion. Should it happen again, restrictive measures will be taken. sabasiddique1 commented on Feb 3, 2026 I’d be happy to work on this if it’s not already assigned.
I’m planning to add a small HOWTO for the cmd module, with a minimal example that:
- explains the default empty‑line behavior, and
- shows how to override
emptyline() and implement do_EOF().
Please let me know if this approach sounds good. picnixz commented on Feb 3, 2026 As long as you do not use an LLM for this task, I would be happy with this addition. However, I want you to have a look at https://docs.python.org/3/howto/index.html. For instance, I would assume that the tutorial on using cmd.Cmd may fall under the same category as for ipaddress but we can also add a section directly at the end of the cmd module, following the simple example https://docs.python.org/3/library/cmd.html#cmd-example, that is, we can just add an example for this empty line behavior.
I think the second option is better as for now, only this specific behavior was a bit confusing to users. Having a full-fledged tutorial may seem an overkill for now. rhettinger commented on Feb 4, 2026 changed the title [-]Add a tutorial for cmd.Cmd[/-] [+]Add a tutorial for cmd.Cmd for `emptyline()` and `do_EOF`[/+] on Feb 4, 2026picnixz commented on Feb 4, 2026 Yeah but that example does not cover this specific issue. So I'm fine with adding another example for emptyline() and do_EOF.
Note: do_EOF does not seem to be documented either (but I'm not sure that the hook is a hook then) Reacted by Anand B Pillai
MetadataMetadataStatusShow more project fields
DevelopmentNo branches or pull requestsIssue actions
|