doc Posted September 23, 2013 Share Posted September 23, 2013 I have a python script that I'm running in the python shell execfile("myscript.py") and I'd liked the script to stop running if a certain condition is met. If I was just writing a normal python script I'd do this: if foo>0 : sys.exit() but when running this in houdini it will attempt tp quit the whole file rather than just the script. Is there a way to exit the script and not the houdini session? thanks Quote Link to comment Share on other sites More sharing options...
yongbin Posted September 24, 2013 Share Posted September 24, 2013 (edited) are your script running in function? then you can use return statement. def foo(): ... if bar>0: returnfoo()[/CODE] Edited September 24, 2013 by yongbin Quote Link to comment Share on other sites More sharing options...
doc Posted September 24, 2013 Author Share Posted September 24, 2013 I wasn't running it in a function, but I'll put it in one and it works like a charm. thanks Quote Link to comment Share on other sites More sharing options...
Erik_JE Posted September 24, 2013 Share Posted September 24, 2013 execfile is bad code imo. Better to create and import a module in most cases Quote Link to comment Share on other sites More sharing options...
glassman3d Posted October 3, 2013 Share Posted October 3, 2013 if you want to simply exit out of a loop but stay in a function you could also use 'break' execfile is bad code imo. Better to create and import a module in most cases double plus one! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.