Tiago Saboga wrote: > <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode > character u'\xe7' in position 2: ordinal not in range(128) > > ======================================= > > What's happening? Why do the readline methods accept a multibyte > string ('ação') but not a unicode (u'ação')?
I don't know what is happening with readline but this error is usually the result of converting a Unicode string to a plain string without specifying encoding, either explicitly by calling str() or implicitly such as in a print statement: In [3]: u='a\303\247\303\243o'.decode('utf-8') In [4]: print u ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in <module> <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 1-2: ordinal not in range(128) In [5]: str(u) ------------------------------------------------------------ Traceback (most recent call last): File "<ipython console>", line 1, in <module> <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode characters in position 1-2: ordinal not in range(128) Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor