[Tutor] Python equiv of Perl's 'or die()' syntax

Deirdre Saoirse deirdre@deirdre.net
Wed, 19 Jul 2000 15:37:27 -0700 (PDT)


On Wed, 19 Jul 2000, Ben Beuchler wrote:

> Is there a simple equivalent to Perl's 'or die()' syntax?
> 
> Similar to this:
> 
> open( MYFILE, 'filethatdoesnotexist') or die "Help me!!:$!"

sure:

def die(printme):
 print printme
 exit(1)

:)

-- 
_Deirdre   *   http://www.sfknit.org   *   http://www.deirdre.net
"Trust me, I'm a science fiction writer" -- Larry Niven @ Conolulu