[Python-Dev] Shouldn't I be able to print Unicode objects?
Michael Hudson
mwh@python.net
05 Jun 2001 19:16:52 +0100
Skip Montanaro <skip@pobox.com> writes:
> Just catching up on a little c.l.py and I noticed the effbot's response to
> the Unicode degree inquiry. I tried to create and print one and got this:
>
> % python
> Python 2.1.1a1 (#9, Jun 4 2001, 11:32:33)
> [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> u"\N{DEGREE SIGN}"
> u'\xb0'
> >>> print u"\N{DEGREE SIGN}"
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> UnicodeError: ASCII encoding error: ordinal not in range(128)
>
> Shouldn't I be able to print arbitrary Unicode objects? What am I missing
> (this time)?
The encoding:
>>> print u"\N{DEGREE SIGN}".encode("latin1")
°
Cheers,
Skippy's little helper.
--
In case you're not a computer person, I should probably point out
that "Real Soon Now" is a technical term meaning "sometime before
the heat-death of the universe, maybe".
-- Scott Fahlman <sef@cs.cmu.edu>