Duncan Booth wrote: > "Stuart McGraw" <[EMAIL PROTECTED]> wrote: > > > So, does raw_input() ever return unicode objects and if > > so, under what conditions? > > > It returns unicode if reading from sys.stdin returns unicode. > > Unfortunately, I can't tell you how to make sys.stdin return unicode for > use with raw_input. I tried what I thought should work and as you can see > it messed up the buffering on stdin. Does anyone else know how to wrap > sys.stdin so it returns unicode but is still unbuffered?
Considering that all consoles are ascii based, the following should work where python was able to determine terminal encoding: class ustdio(object): def __init__(self, stream): self.stream = stream self.encoding = stream.encoding def readline(self): return self.stream.readline().decode(self.encoding) sys.stdin = ustdio(sys.stdin) answer = raw_input() print type(answer) -- http://mail.python.org/mailman/listinfo/python-list