@@ -169,42 +169,20 @@ required syntactically but the program requires no action. For example::
169169 ... pass # Busy-wait for keyboard interrupt (Ctrl+C)
170170 ...
171171
172- This is commonly used for creating minimal classes such as exceptions, or
173- for ignoring unwanted exceptions::
172+ This is commonly used for creating minimal classes::
174173
175- >>> class ParserError(Exception) :
174+ >>> class MyEmptyClass :
176175 ... pass
177- ...
178- >>> try:
179- ... import audioop
180- ... except ImportError:
181- ... pass
182- ...
176+ ...
183177
184178Another place :keyword: `pass ` can be used is as a place-holder for a function or
185- conditional body when you are working on new code, allowing you to keep
186- thinking at a more abstract level. However, as :keyword: `pass ` is silently
187- ignored, a better choice may be to raise a :exc: `NotImplementedError `
188- exception::
179+ conditional body when you are working on new code, allowing you to keep thinking
180+ at a more abstract level. The :keyword: `pass ` is silently ignored::
189181
190182 >>> def initlog(*args):
191- ... raise NotImplementedError # Open logfile if not already open
192- ... if not logfp:
193- ... raise NotImplementedError # Set up dummy log back-end
194- ... raise NotImplementedError('Call log initialization handler')
183+ ... pass # Remember to implement this!
195184 ...
196185
197- If :keyword: `pass ` were used here and you later ran tests, they may fail
198- without indicating why. Using :exc: `NotImplementedError ` causes this code
199- to raise an exception, telling you exactly where the incomplete code
200- is. Note the two calling styles of the exceptions above.
201- The first style, with no message but with an accompanying comment,
202- lets you easily leave the comment when you remove the exception,
203- which ideally would be a good description for
204- the block of code the exception is a placeholder for. However, the
205- third example, providing a message for the exception, will produce
206- a more useful traceback.
207-
208186.. _tut-functions :
209187
210188Defining Functions
0 commit comments