Issue 4247: Docs: Provide some examples of "pass" use in the tutorial. (original) (raw)

I'm giving a Python tutorial to a bunch of local people and have decided to use the Python.org tutorial to go by. One of the things I found I wanted in the section on the "pass" statement was more information about it's use. But I also think it's worth mentioning using the NotImplementedError if pass is used for stubbing out code.

This patch to the tutorial includes some example use cases, and also a reference to NotImplementedError. I would appreciate some review however, as I'm not sure this discussion is appropriate.

Included below is the patch, for ease of reading, but it's also attached as a patch (taken against trunk today).

Sean

Index: Doc/tutorial/controlflow.rst

--- Doc/tutorial/controlflow.rst (revision 67072) +++ Doc/tutorial/controlflow.rst (working copy) @@ -166,7 +166,36 @@ ... pass # Busy-wait for keyboard interrupt (Ctrl+C) ...

+This is commonly used for creating minimal classes like with exceptions, or +for skipping unwanted exceptions::

I originally had that, but then I realized that if I make it a comment I can then do something like "dw." on that line when I start filling in the code to keep the comment around. Because I find that when I fill in the high level comments they make nice comments to keep around for that code block.

I'm open to the exception string, but I deliberately switched from the string to comment.

Sean