Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100436 > unrolled thread
| Started by | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| First post | 2015-12-15 10:19 +1100 |
| Last post | 2015-12-15 10:19 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
EAFP and LBYL (was: Try: rather than if :) Ben Finney <ben+python@benfinney.id.au> - 2015-12-15 10:19 +1100
| From | Ben Finney <ben+python@benfinney.id.au> |
|---|---|
| Date | 2015-12-15 10:19 +1100 |
| Subject | EAFP and LBYL (was: Try: rather than if :) |
| Message-ID | <mailman.2.1450135199.22044.python-list@python.org> |
Vincent Davis <vincent@vincentdavis.net> writes: > In the code below try is used to check if handle has the attribute name. It > seems an if statement could be used. Is there reason one way would be > better than another? The Python community refers to the difference by contrasting “look before you leap” (LBYL) versus “easier to ask forgiveness than permission” (EAFP), and tends to prefer the latter. <URL:http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html#eafp-vs-lbyl> “It is easier to ask forgiveness than permission” is attributed to computer programming legend Rear Admiral Grace Hopper (she who documented the first actual computer bug — a large moth in the wires). Alex Martelli explores when LBYL and EAFP are each appropriate in Python <URL:http://pyvideo.org/video/1338/permission-or-forgiveness-0>. -- \ “The optimist thinks this is the best of all possible worlds. | `\ The pessimist fears it is true.” —J. Robert Oppenheimer | _o__) | Ben Finney
Back to top | Article view | comp.lang.python
csiph-web