On Mon, Apr 22, 2013 at 10:37 AM, <jus...@zeusedit.com> wrote: > Can someone please explain the following behaviour? > > If I run the macro using the -u (flush buffers) option the if statement > always fails: > > C:\Temp>python.exe -u c:\temp\test.py > Please Input 120: > 120 > Value Inputed: 120 > No
Here's the essence of your program: print(repr(raw_input())) You can use that to verify what's going on. Try running that with and without the -u option; note, by the way, that -u actually means "unbuffered", not "flush buffers". You're running this under Windows. The convention on Windows is for end-of-line to be signalled with \r\n, but the convention inside Python is to use just \n. With the normal use of buffered and parsed input, this is all handled for you; with unbuffered input, that translation also seems to be disabled, so your string actually contains '120\r', as will be revealed by its repr(). By the way, raw_input() already returns a string. There's no need to str() it. :) ChrisA -- http://mail.python.org/mailman/listinfo/python-list