EAFP vs LBYL (was Re: A little disappointed so far)

Robin Becker robin at jessikat.fsnet.co.uk
Wed May 21 04:00:53 EDT 2003


In article <38ec68a6.0305202129.84ded31 at posting.google.com>, Asun Friere
<afriere at yahoo.co.uk> writes
>Robin Becker <robin at jessikat.fsnet.co.uk> wrote in message news:<Qr6V9KAUCfy+Ewh
>H at jessikat.demon.co.uk>...
>
>> well I hope you're not flying with engineering like
>> 
>> try:
>>         igniteKerosene()
>> except ExplosionError:
>>         handleExplosionCase()
>> 
>> :)
>
>As long as the engineers actually have some way of handling the
>explosion, what's the problem. :p
> 
>BTW, there's this neat device called the 'internal combustion engine'
>which  ... ;)
well I was thinking there might be some cheaper way

while flammableMixture():
        sleep(1)
igniteKerosene()


but since, as Alex says, we can't guarantee anything we probably still
need the try ie

while flammableMixture():
    sleep(1)
try:
    igniteKerosene()
except ExplosionError:
    handleExplosionCase()       #call lawyers etc
except FlameWentOutError:
    blameSuppliersEtc()
except EndOfUniverseError:
    pray()
...... other exceptions
 

-- 
Robin Becker




More information about the Python-list mailing list