PEP 263 comments

Neil Hodgson nhodgson at bigpond.net.au
Sat Mar 2 07:30:26 EST 2002


Martin v. Loewis:
> bokr at oz.net (Bengt Richter) writes:
>
> > Will the following work?
> >
> >  >>> print u'\u0041'
> >  A
> >  >>> print u'\u221e'
> >
> >  Traceback (most recent call last):
> >    File "<stdin>", line 1, in ?
> >  UnicodeError: ASCII encoding error: ordinal not in range(128)
> >  >>>
>
> With the patch to print Unicode to the Windows console, the
> UnicodeError will be gone. Whether or not Lucida Unicode supports that
> character, I cannot say.

   It does, it is an infinity symbol and is available in most Windows
fonts - Verdana, Times New Roman, ...

> > And if I redirect the output to a file, what will be in the file?
>
> Since the isatty test fails, the system default encoding will be used.
> Unless you've changed that, you'll get a UnicodeError again.

   How do you tell Python to treat stdout as a tty even though it is
actually a pipe? I'd like to run Unicode printing programs from within SciTE
with I/O redirected to SciTE's output pane. There is also an issue with
stdin where I'd like to tell Python to treat redirected input, fed through a
pipe, as a tty.

   Neil






More information about the Python-list mailing list