Re: Persistent failure of 'break' statement ( novice )



On Sat, 13 Jun 2009 19:03:38 -0700 (PDT), John Machin
<sjmachin@xxxxxxxxxxx> wrote:

On Jun 14, 10:20 am, pdlem...@xxxxxxxxxxxxx wrote:

Now no error message, but it will go on forever despite repeatedly
entering 0.  Have to get out with ctrl-c .    

           Frusting: I'm missing something fundamental. Dave WB3DWE

After you hit the zero key, do you hit the Enter key?

If the answer is yes, then our crystal balls have proved useless.
You'll have to supply some meaningful detail. If you are pasting your
script into a Python interactive prompt, stop doing that, save your
script as a file, and run it from the command line.

Here's a script for you to use. It has some diagnostic print() calls
in it so that we can see what is going wrong.

8<----- cut here
import sys
print(sys.version)
assert sys.version.startswith('3.')
while True :
text = input('Enter a number -> ')
print('You entered', ascii(text))
if text != "0":
print('That is NOT the digit zero!')
num = int(text)
print('Value:', num)
if num == 0:
break
print('done')
8<----- cut here

And when you run it, copy the outout and paste it into your return
message/posting, like I've done below:

[I called my copy break_fail.py]

C:\junk>\python30\python break_fail.py
3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit (Intel)]
Enter a number -> 9
You entered '9'
That is NOT the digit zero!
Value: 9
Enter a number -> 0
You entered '0'
Value: 0
done

C:\junk>

Hoping this helps,
John


John : Hitting Enter solved it. Thanks so much. I was treating
input() as getch() or getche() . Dave WB3DWE
.



Relevant Pages

  • Re: Persistent failure of break statement ( novice )
    ... After you hit the zero key, do you hit the Enter key? ... script as a file, and run it from the command line. ... print('Value:', num) ...
    (comp.lang.python)
  • Re: for each file loop question on reading variables
    ... Is the thing that you want to do based on filename a control lfow thing or is it a data thing. ... In the Control Flow you may want to use the Script task. ... If what you want to do is simply make a FF Connection Manager point to this new file then you need to look at property expressions. ... Highlight the Conection Manager, hit F4, ind the Expressions item and hit the ellipses. ...
    (microsoft.public.sqlserver.dts)
  • Re: process a BIG string
    ... I won't hit the memory limit because i only read about 10 to 64Kb at a ... in buffers of about 8192bytes and process each buffer, ... the problem is that with large filesi get a script error(Fatal ... You might also hit the roof of your memory usage if you handle and process ...
    (comp.lang.php)
  • Re: import magic
    ... Then I run this Funduc script to tidy it up. ... Before Hit=< ... Display Replace String=0 ... Min Date Filter= ...
    (comp.lang.java.programmer)
  • BASH vs Expect
    ... me in charge of the unix boxes. ... and the internal server room. ... having said that - I must admit I'm script stupid. ... I've got a monitoring server that's internal that will hit the ...
    (comp.unix.shell)