raw_input weirdness -- shell's fault?

Jonadab the Unsightly One jonadab at bright.net
Tue Sep 5 20:45:07 EDT 2000


I'm getting some weirdness when calling a python script that
does raw_input.  It works okay from COMMAND.COM, but when I
call it from eshell I get this...

e:/a/python/jonadab/exp $ python args.py
blah
foo
y
(y/n) ? Yes or no, please!
(y/n) ? Yes or no, please!
(y/n) ? e:/a/python/jonadab/exp $ 

That is, the prompts weren't printed until the script
exited.  Is this normal?  It seems weird to me...  maybe
this is an eshell idiosyncracy?  But this is the first I've
noticed it...  I'm using eshell 2.3, BTW, in NTEmacs 20.7.1,
and Python 1.5.2 (final) (which IIRC I downloaded from
ActiveState, but I'm not certain I RC).

I'd prefer to be able to call my python scripts from
eshell; it would make my life a lot easier if I didn't
have to mess with switching windows all the time while
I'm trying to learn a language.  TIA for any suggestions.

Oh, and here's the test script I was using...

# Filched from the Tutorial by Guido van Rossum...

def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
    while 1:
        ok = raw_input(prompt)
        if ok in ('y', 'ye', 'yes'): return 1
        if ok in ('n', 'no', 'nop', 'nope'): return 0
        retries = retries - 1
        if retries < 0: raise IOError, 'refusenik user'
        print complaint

ask_ok('(y/n) ? ')

- jonadab



More information about the Python-list mailing list