can somebody help me with the following piece of the code:
try:
#do some things
myClass.close()
except Exception, error:
myClass.close()
raise error
as You see I can’t use here finally because in that case I will not know if an error actually occured, and I need to raise this error (raise error)
my question is how can I avoid using this two times myClass.close()? thanks in advance for any help
This is equivalent to your code:
First it calls
myClass.close()and if there was a error it is raised again.You can also have this to handle specific exceptions: