[Tutor] Help concerning raw_input urgently needed!

Kyle Babich kyle@sent.com
Sun, 1 Sep 2002 22:51:20 UT


On Mon, 02 Sep 2002 00:01:29 +0200, "Gregor Lingl" <glingl@aon.at>
said:
> Some ten days ago I posted the following to idle-dev, but
> the message went into a wrong thread and was consequently
> ignored. So I try it again, this time also at tutor. Several colleagues
> asked me already, why this Error occurs - I still can only reply:
> I don't know.
> By the way: does this Error also occur when working with IDLE on
> a Linux-machine? (Aren't there people with happy little Linux-Systems
> in Berlin, who could check this easily?)
> --------------
>=20
> Some month ago I copied sitecustomize.py with
> appropriate locale-setting to C:\Python22\Lib
> thanks to an advice of someone on this list.
>=20
> This worked well until today I made the observation,
> that raw_input doesn't work correctly:
>=20
>  >>> a =3D raw_input("H=E4? ")
> H=E4? Tsch=FCs
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in ?
>     a =3D raw_input("H=E4? ")
> TypeError: object.readline() returned non-string
>  >>>
>=20

The program expects the raw_input to return a string, but Tsch=FCs
according to python doesn't qualify.

>>> type("Tsch=FCs")
UnicodeError: ASCII encoding error: ordinal not in range(128)

A better idea might be to use sys.stdin.readline().

>>> import sys
>>> a =3D sys.stdin.readline()
Tsch=FCs
>>> print a
Tsch=FCs

> Consequently I cannot execute programs with
> raw_input from IDLE, if the expected answers (inputs)
> may contain "Umlaute". Those same programs,
> however, can be executed from the commandline.
> And also the interactive Python interpreter can execute
> raw_input statements even when Umlaute are input.
>=20
> So I think, this must be a problem of IDLE.
> I must confess, I do not understand the error message.
>=20
> Hope this can be corrected somehow.
> Thanks
>=20
> Gregor Lingl
>=20
>=20
>=20
>=20
>=20
>=20
>=20
>=20
>=20
>=20
>=20
>=20
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>=20