Mercurial > cpython-lru_cache-weakref
diff Doc/tutorial/errors.rst @ 50563:93cf3a6ead63 3.0
Merged revisions 68226 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k
........
r68226 | georg.brandl | 2009-01-03 22:18:54 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove trailing whitespace.
........
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Sun, 04 Jan 2009 00:04:26 +0000 |
| parents | 30ef22a80267 |
| children | d2732ea99ba0 |
line wrap: on
line diff
--- a/Doc/tutorial/errors.rst Sun Jan 04 00:02:52 2009 +0000 +++ b/Doc/tutorial/errors.rst Sun Jan 04 00:04:26 2009 +0000 @@ -91,7 +91,7 @@ ... break ... except ValueError: ... print("Oops! That was no valid number. Try again...") - ... + ... The :keyword:`try` statement works as follows. @@ -195,12 +195,12 @@ >>> def this_fails(): ... x = 1/0 - ... + ... >>> try: ... this_fails() ... except ZeroDivisionError as err: ... print('Handling run-time error:', err) - ... + ... Handling run-time error: int division or modulo by zero @@ -251,12 +251,12 @@ ... self.value = value ... def __str__(self): ... return repr(self.value) - ... + ... >>> try: ... raise MyError(2*2) ... except MyError as e: ... print('My exception occurred, value:', e.value) - ... + ... My exception occurred, value: 4 >>> raise MyError('oops!') Traceback (most recent call last): @@ -326,7 +326,7 @@ ... raise KeyboardInterrupt ... finally: ... print('Goodbye, world!') - ... + ... Goodbye, world! Traceback (most recent call last): File "<stdin>", line 2, in ? @@ -389,9 +389,9 @@ print(line) The problem with this code is that it leaves the file open for an indeterminate -amount of time after this part of the code has finished executing. -This is not an issue in simple scripts, but can be a problem for larger -applications. The :keyword:`with` statement allows objects like files to be +amount of time after this part of the code has finished executing. +This is not an issue in simple scripts, but can be a problem for larger +applications. The :keyword:`with` statement allows objects like files to be used in a way that ensures they are always cleaned up promptly and correctly. :: with open("myfile.txt") as f:
