mirror of
https://github.com/python/cpython.git
synced 2025-11-27 13:45:25 +00:00
Fix grammar error; reword two paragraphs
This commit is contained in:
parent
a8bb5506a6
commit
fcdc80bfd2
1 changed files with 11 additions and 9 deletions
|
|
@ -166,8 +166,8 @@ required syntactically but the program requires no action. For example::
|
||||||
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
|
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
|
||||||
...
|
...
|
||||||
|
|
||||||
This is commonly used for creating minimal classes like with exceptions, or
|
This is commonly used for creating minimal classes such as exceptions, or
|
||||||
for skipping unwanted exceptions::
|
for ignoring unwanted exceptions::
|
||||||
|
|
||||||
>>> class ParserError(Exception):
|
>>> class ParserError(Exception):
|
||||||
... pass
|
... pass
|
||||||
|
|
@ -178,7 +178,7 @@ for skipping unwanted exceptions::
|
||||||
... pass
|
... pass
|
||||||
...
|
...
|
||||||
|
|
||||||
Another place it can be used is as a place-holder for a function or
|
Another place :keyword:`pass` can be used is as a place-holder for a function or
|
||||||
conditional body when you are working on new code, allowing you to keep
|
conditional body when you are working on new code, allowing you to keep
|
||||||
thinking at a more abstract level. However, as :keyword:`pass` is silently
|
thinking at a more abstract level. However, as :keyword:`pass` is silently
|
||||||
ignored, a better choice may be to raise a :exc:`NotImplementedError`
|
ignored, a better choice may be to raise a :exc:`NotImplementedError`
|
||||||
|
|
@ -193,12 +193,14 @@ exception::
|
||||||
|
|
||||||
If :keyword:`pass` were used here and you later ran tests, they may fail
|
If :keyword:`pass` were used here and you later ran tests, they may fail
|
||||||
without indicating why. Using :exc:`NotImplementedError` causes this code
|
without indicating why. Using :exc:`NotImplementedError` causes this code
|
||||||
to raise an exception, allowing you to tell exactly where code that you
|
to raise an exception, telling you exactly where the incomplete code
|
||||||
need to complete is. Note the two call styles of the exceptions above.
|
is. Note the two calling styles of the exceptions above.
|
||||||
The comment style is useful in that when you remove the exception you can
|
The first style, with no message but with an accompanying comment,
|
||||||
easily leave the comment, which ideally would be a good description for
|
lets you easily leave the comment when you remove the exception,
|
||||||
the block of code the exception is a placeholder for. The call-style
|
which ideally would be a good description for
|
||||||
will raise a more useful exception however.
|
the block of code the exception is a placeholder for. However, the
|
||||||
|
third example, providing a message for the exception, will produce
|
||||||
|
a more useful traceback.
|
||||||
|
|
||||||
.. _tut-functions:
|
.. _tut-functions:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue