[Tutor] changing a variable with raw_input

richard kappler richkappler at gmail.com
Wed Sep 16 19:14:59 CEST 2015


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 <richkappler at gmail.com>
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
>



-- 

All internal models of the world are approximate. ~ Sebastian Thrun


More information about the Tutor mailing list