[Tutor] Python equiv of Perl's 'or die()' syntax
Wed, 19 Jul 2000 17:47:47 -0500
On Thu, Jul 20, 2000 at 12:22:42AM +0200, Remco Gerlich wrote:
> To catch exceptions, you use the try: except: construct, like
> f = open("filethatdoesnotexist","r")
> except IOError:
> print "File open failed!"
> # Do the rest of your error handling...
Hmmm... OK. I understand how that works. Now, since I would like to
include that kind of syntax on almost every file I open, any thoughts on
doing something like this:
handle = open(filename)
print "Opening", filename, "failed!!"
And calling it thusly:
Would that make sense as a shortcut?
Ben Beuchler firstname.lastname@example.org
MAILER-DAEMON (612)-321-9290 x101
Bitstream Underground www.bitstream.net