[Tutor] try except block for multiple statements

Bryan Fodness bryan.fodness at gmail.com
Tue Dec 2 02:44:20 CET 2008

I would like to use a try except to see if a value exists.  But, when I use
the following, if a does not exist it exits.  I understand why this does
this, but is there a way to get b,c, and d if a does not exist without using
a try except for every statement?

    fo.write("a = %s\n" %plan.a)
    fo.write("b = %s\n" %plan.b)
    fo.write("c = %s\n" %plan.c)
    fo.write("d = %s\n" %plan.d)
except AttributeError:

"Any intelligent fool can make things bigger, more complex, and more
violent. It takes a touch of genius - and a lot of courage - to move in the
opposite direction. "  -Albert Einstein
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081201/824c38fc/attachment.htm>

More information about the Tutor mailing list