Hi,
I have a function, looks a bit like this:
def function():
To break out I have tried just sticking a return in the else clause, I've also tried raising an exception (StandardError( )) in the else clause and then catching it in an Except outside of the function, then moving on.
However when stepping through in PyWin's debugger, for both the above attempts the function does the 'stuff' successfully, reaches the else clause fine, hits the return, or the exeption is caught fine. But despite this, the program always then jumps back to some of the recursive calls within the if clause.
I just want it to end when it hits the else!
Any help would be much appreciated, I am an obvious newbee, so hopefully this problem has an obvious solution!
I'm running Py2.5 on XPpro, using PyWin to edit and debug. The 'stuff' involves processing some XML, I'm using lxml2.0.1.
Thanks in advance,
Nathan
I have a function, looks a bit like this:
def function():
if condition:
do stuff, including a few recursive calls (to function()),
this 'stuff' also changes the state of 'condition'.
'condition' is a global list.
this 'stuff' also changes the state of 'condition'.
'condition' is a global list.
else:
I want to break out of the function and move on
To break out I have tried just sticking a return in the else clause, I've also tried raising an exception (StandardError( )) in the else clause and then catching it in an Except outside of the function, then moving on.
However when stepping through in PyWin's debugger, for both the above attempts the function does the 'stuff' successfully, reaches the else clause fine, hits the return, or the exeption is caught fine. But despite this, the program always then jumps back to some of the recursive calls within the if clause.
I just want it to end when it hits the else!
Any help would be much appreciated, I am an obvious newbee, so hopefully this problem has an obvious solution!
I'm running Py2.5 on XPpro, using PyWin to edit and debug. The 'stuff' involves processing some XML, I'm using lxml2.0.1.
Thanks in advance,
Nathan
Comment