On 02/21/2014 05:21 PM, Steven D'Aprano wrote: > On Sat, Feb 22, 2014 at 01:15:13PM +1300, Greg Ewing wrote: >> >> With an except expression, it could be written: >> >> result = computation(int(arg) >> except ValueError: abort("Invalid int")) > > Nice example! Except I'd lay the code out a bit better to emphasise > which part is being guarded: > > result = computation( > int(arg) except ValueError: abort("Invalid int") > ) > > Actually, not quite so nice as I first thought, since you're relying on > the side-effects of abort() rather than returning a value. Think of it rather as transforming the exception to be more useful. -- ~Ethan~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4