On 16/09/2015 18:14, richard kappler wrote:
Nevermind, figured it out. it needed to be delay = 0 and delay = 0.5, not ==
regards, Richard the virus ridden
On Wed, Sep 16, 2015 at 1:03 PM, richard kappler <[email protected]>
wrote:
Missing something obvious here, but down with the flu so I'm foggy and
just can't see it. I need to set a variable 'delay' to be used in
time.sleep(delay) later on in a script, based on user input. Something odd
is going on in setting the variable though. Here's the snippet where I'm
trying to set the variable:
#!/usr/bin/env python
delay = 7
print("1 - Batch")
print("2 - 2 per second")
print("3 - Real Time")
choice = raw_input("Enter feed speed choice (then press enter): ")
choice = int(choice)
if choice == 1:
print "running as batch"
delay == 0
elif choice == 2:
print "feeding 2 events per second"
delay == 0.5
elif choice == 3:
print "feeding real time"
delay = 'real time'
else:
print "choice not available"
os._exit(0)
print 'delay = ' + str(delay)
If I enter 1 or 2, I get delay = 7, if I enter 3, I get delay = real time.
HUH???
regards, Richard
--
All internal models of the world are approximate. ~ Sebastian Thrun
I suggest that you learn a little about debugging problems like this,
such as putting print statements into your code or actually stepping
through your code in a debugger.
Would you also be kind enough not to top post here, it can make things
very difficult to read in long threads, thanks.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor