"Martin v. Löwis" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
> Stuart McGraw schrieb:
> > So, does raw_input() ever return unicode objects and if
> > so, under what conditions?
>
> At the moment, it only returns unicode objects when invoked
> in the IDLE shell, and only if the character entered cannot
> be represented in the locale's charset.

Thanks for the answer.

Also, if anyone has a solution for Duncan Booth's attempt
to wrap stdin, I would find it very useful too!

"Duncan Booth" <[EMAIL PROTECTED]> 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?
>
> Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]
> on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sys, codecs
> >>> sys.stdin.encoding
> 'cp437'
> >>> sys.stdin = codecs.getreader(sys.stdin.encoding)(sys.stdin)
> >>> raw_input()
> hello world
> still going?
> ^Z
> ^Z
> u'hello world'
> >>>

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to