def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
ok = raw_input(prompt)
if ok in ('y', 'yes'):
if ok in ('n', 'no'):
retries = retries - 1
if retries < 0:
raise IOError, 'refusenik user'
flag = ask_ok('are you really want to quit?')
if flag == True:
In Eclipse 3.2/Python 2.4,the output always is"Yes or no, please! "
however,if you add a '\r' after the word which compare with 'ok',e.g.'y'->'y\r'. Then the result will be right.
So,I guess Pydev don't have a good deal with the 'enter'.It should only be the end of input,not in the input.
if you use IDLE,there is no problem
Nope, this is a python bug mixed with a bad specification on how a shell is supposed to behave.
Usually shells put a '\n' when you press enter, but the Eclipse console puts '\r\n' and python does not handle it well, as this is not specified anywhere, and does not seem such awkward, my feeling is that it's a python bug, but you can surely argue the other way... so, you can submit a bug to eclipse.org and python.org and see who'll fix it... (or you can handle it in your program).
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.