raw_input(), STRANGE behaviour

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Sun Jan 27 19:55:18 CET 2008

En Sun, 27 Jan 2008 12:51:51 -0200, Dox33 <Rens.Duijsens at gmail.com>  

> Yes, I know.
> There are several ways to work around the problem.
> (Look at the innitial code I provided in this discussion start)
> Fact is, every time I'm getting a script from somewhere or someone, I
> have to search and replace all the affected code.
> Not very conveniant.
> That's why I rather would have a correct working version.

Add this on your sitecustomize.py module (or create one)

import sys

def raw_input(prompt=None):
   if prompt: sys.stdout.write(prompt)
   return original_raw_input()

import __builtin__
original_raw_input = __builtin__.raw_input
__builtin__.raw_input = raw_input

It just replaces the builtin raw_input with a custom function.

Gabriel Genellina

More information about the Python-list mailing list