![]() |
Why did %S break my if statement?
I was working on an if statement inside a function (see below for code) and made the small typo of %S instead of %s inside of one of my print statements. For some reason this caused the program to exit the function immediately. Can someone explain exactly what that is doing?
I don't know that it matters, but here is the function with the location of the (now former) typo in red. The gratuitous print statments that I used to help me debug are still in there, so you can ignore them. :
def remove_person(): |
What do you mean it "exited the function"? It should be raising a ValueError, since %S is an unsupported format character. Is this Python 2.4?
|
!!! It makes so much sense now. It was rasing a ValueError, but that function was run from inside a try block. just before the function is called, I'd had the program try int(some.user.input) and had a ValueError exception ready in case of bad input.
That function was called at option[choice]() below. :
while choice != 9: # main menu loop |
Ahh. Excellent. What a sucker those things can be. My first thought was you had it in a try, since you didn't mention raising any errors. But I couldn't see that anywhere in your code. Very well. :P
|
| All times are GMT -5. The time now is 8:03 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC