[Python-Dev] Shouldn't I be able to print Unicode objects?

Skip Montanaro skip@pobox.com (Skip Montanaro)
Tue, 5 Jun 2001 15:47:17 -0500


    mal> Please see Lib/site.py for details on how to enable all these
    mal> goodies -- it's all there, just disabled and meant for super-u=
sers
    mal> only ;-)

Okay, I found the encoding section.  I changed the encoding variable
assignment to be

    encoding =3D "latin1"

and now the degree sign print works.  What other side-effects will that=
 have
besides on printed representations?  It appears I can create (but not s=
ee
properly?)  variable names containing latin1 characters:

>>> =FCmlaut =3D "=FCmlaut"
>>> print locals().keys()
['orca', 'dir', '__doc__', 'rlcompleter', 'missionb', 'version', 'dirpa=
t', 'xmlrpclib', 'belugab', '__builtin__', 'beluga', 'readline', '__nam=
e__', 'orcab', 'addpath', 'Writer', 'atexit', 'sys', 'dolphinb', 'missi=
on', 'pprint', 'dolphin', '__builtins__', 'mlaut', 'help']

I am having trouble printing some strings containing latin1 characters:=


>>> print =FCmlaut
mlaut
>>> type("=FCmlaut")
<type 'string'>
>>> type(string.letters)
<type 'string'>
>>> print "=FCmlaut"
mlaut
>>> print string.letters
abcdefghijklmnopqrstuvwxyz=B5=DF=E0=E1=E2=E3=E4=E5=E6=E7=E8=E9=EA=EB=EC=
=ED=EE=EF=F0=F1=F2=F3=F4=F5=F6=F8=F9=FA=FB=FC=FD=FE=FFABCDEFGHIJKLMNOPQ=
RSTUVWXYZ=C0=C1=C2=C3=C4=C5=C6=C7=C8=C9=CA=CB=CC=CD=CE=CF=D0=D1=D2=D3=D4=
=D5=D6=D8=D9=DA=DB=DC=DD=DE
>>> print string.letters[55:]
=FC=FD=FE=FFABCDEFGHIJKLMNOPQRSTUVWXYZ=C0=C1=C2=C3=C4=C5=C6=C7=C8=C9=CA=
=CB=CC=CD=CE=CF=D0=D1=D2=D3=D4=D5=D6=D8=D9=DA=DB=DC=DD=DE

The above was pasted from Python running in a shell session in XEmacs, =
which
is certainly latin1-aware.  Why did I have trouble seeing the =FC in so=
me
situations, but not in others?

Are the ramifications of all this encoding stuff documented somewhere?

Skip