I'm parsing html and i'm doing:

x = root.find_class(...
y = root.find_class(..
z = root.find_class(..

all 3 are likely to fail so typically i'd have to stick it in a try. This is 
a huge pain for obvious reasons.

try:
 ....
except something:
 x = 'default_1'
(repeat 3 times)

Is there some other nice way to wrap this stuff up?
I can't do:
try:
 x=
 y=
 z=
except:

because here if x fails, y and z might have succeeded.

Pass the statement as a string to a try function? Any other way?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to