Skip to content

gh-144338: Improve cmd.Cmd docs for emptyline() and do_EOF#145292

Open
Anandesh-Sharma wants to merge 1 commit intopython:mainfrom
Anandesh-Sharma:fix-cmd-emptyline-docs
Open

gh-144338: Improve cmd.Cmd docs for emptyline() and do_EOF#145292
Anandesh-Sharma wants to merge 1 commit intopython:mainfrom
Anandesh-Sharma:fix-cmd-emptyline-docs

Conversation

@Anandesh-Sharma
Copy link

@Anandesh-Sharma Anandesh-Sharma commented Feb 26, 2026

Summary

Addresses #144338 by improving the cmd.Cmd documentation to make the emptyline() and do_EOF patterns more discoverable:

  • Add a note to cmdloop() docs that do_EOF should be defined to handle Ctrl-D/EOF gracefully, with a cross-reference to the example
  • Add a practical tip to emptyline() docs about overriding with pass to suppress the default repeat-last-command behavior
  • Add emptyline() and do_EOF() methods to the existing TurtleShell example to demonstrate these common patterns

These are the two most commonly needed overrides that new cmd.Cmd users struggle to discover from the current documentation.

Closes #144338

Test plan

  • Documentation builds without warnings
  • Example code in docs is syntactically correct

📚 Documentation preview 📚: https://cpython-previews--145292.org.readthedocs.build/

- Document that do_EOF should be defined to handle Ctrl-D gracefully,
  with a cross-reference to the example
- Add a note to emptyline() docs about overriding with pass to suppress
  the default repeat-last-command behavior
- Add emptyline() and do_EOF() to the TurtleShell example to demonstrate
  these common patterns

Closes python#144338

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Add a tutorial for cmd.Cmd for emptyline() and do_EOF

1 participant