Apparently, elif/elseisthe preferred solution where other languages might use a switch statement. I don’t really like the way it looks, but I have to admit the reasoning is sound and it works the same way (which the exception of case fall-through, which is arguably more of a bug than a feature).
As for raw_input, I disagree: just because you have to do it in most cases doesn’t mean it’s not dry. The alternative is to put it into a function that does the same thing, but then you have to call that function repeatedly, so what have you accomplished? un-pythonic.
Another possibility would be
while running == True:
status = raw_input()
if clockedIn = False:
# etc. ...
Obviously, the status doesn’t need to be updated when you stop, but would it hurt anything?
Sorry, I think we got mixed up somewhere. Given your situation, I would normally use a switch statement. Given the fact that python doesn’t have a switch statement, I would use if/elif/else (as you did). I was just pointing out that that appears to be the “correct” solution anyway.
If you’re talking about the raw_input question, I was asking if you could just leave out the status assignment in each case, since you already did it anyway (at the beginning of the while loop). Is there a reason for assigning it again?
I wrote this stupidly because I’m printing all the questions/prompts. I could just use raw_input(arg) and put the prompt where the arg is. Plus, I’m pretty sure I could use argv instead of raw_input. There are only 3 options, raw_input isn’t really the best idea here. It’s not like I’m going to perform some wizardry on whatever garbage string they give me. It’s either option 1, 2 or 3.
Poorly written. But… that’s what new git commits are for!
You’ve undoubtedly seen this but if you haven’t… you both know how to do math. I still find it interesting. Sometimes it’s good to spend time revamping your workflow… even if you have to write an app yourself.
Might help you understand your place in the world as you embark on learning this fine language.
HA HA HA HA! So true! Although… DAMN! I had no idea everyone thinks they’re superior to Java programmers. I mean, I learned Java in a CS class like everybody else in college and didn’t like it but… I have a little more respect for that language in particular.
Also… for me, C is the holy grail. When I can learn that, I’ll truly ‘feel’ like a real programmer.