Commit d054ac5
committed
readability/EAFP: update to Py 3, use specific exception, add race condition note
Add a note about the non-EAFP example code also having a potential race
condition (which is one of the reasons why the EAFP style is preferred).
Update best practice code to catch the specific FileNotFoundError (new
in Python 3.3), instead of the overly broad OSError. (Add note about
using OSError in Python 2, but caution that it may be too broad.)
Update glossary link to point to Python 3 docs, for good measure.1 parent b4b7c23 commit d054ac5
File tree
1 file changed
+7
-3
lines changed- docs/readability
1 file changed
+7
-3
lines changedLines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
34 | | - | |
| 38 | + | |
35 | 39 | | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | | - | |
| 44 | + | |
41 | 45 | | |
42 | 46 | | |
0 commit comments