View Full Version : Can I use sys.exit() ?
I'm currently writing a Python script and I tried to add some exception handling but XBMC seems to crash when I do something like this:
for tries in range(5):
try:
....
except:
if tries==5:
sys.exit(1)
The odd thing is that it doesn't happen when I directly call sys.exit(). I'd rather use a "goto label" to jump to the end of script but the label/goto libs don't seem to be available on XBMC. Anyway knows how to fix this?
Please note that I'm still sort of a novice concerning Python coding.
althekiller
2008-11-20, 00:19
Nah it's busted. I noticed it too, but it was too late to fix for Atlantis. Definitely needs sorting. I'll try to make some time to look at it tonight.
Nah it's busted. I noticed it too, but it was too late to fix for Atlantis. Definitely needs sorting. I'll try to make some time to look at it tonight.
Thanks! Would it also be possible to implement goto/labels in the Python framework? Or do you want me to create a trac ticket for this (and maybe for the sysexit() issue too)?
althekiller
2008-11-20, 20:36
Go ahead and make a bug report for the sys.exit() thing. You can make a feat. req. for the goto thing, but I personally have no interest in enabling a means to bad programming. The only somewhat acceptable (EXTREMELY RARE!) time to use goto, IMO, is in a complex switch statement (python doesn't even have a switch statement ;)).
Nuka1195
2008-11-21, 01:32
"goto" only in dos batch files :P
Of course being a programmer myself I also try to stay away from goto/labels. The last time I used it was probably in the Basic-ages. But in this case it could have been an alternative to the broken sysexit()
althekiller
2008-11-21, 19:06
My alt was a nasty tree of ifs. Make sure your tab spacing is narrow!
My alt was a nasty tree of ifs. Make sure your tab spacing is narrow!
I *always* use 2-space tabs :-D Although I'd rather use a nasty goto/label than having a nasty tree of ifs ;-)