[Python-3000] Displaying strings containing unicode escapes at the interactive prompt

Guido van Rossum guido at python.org
Wed Apr 16 16:26:36 CEST 2008


2008/4/16 Oleg Broytmann <phd at phd.pp.ru>:
>    The problem manifests itself in scripts, too:
>
>  Traceback (most recent call last):
>   File "./ttt.py", line 4, in <module>
>     open("тест") # filename is in koi8-r encoding
>  IOError: [Errno 2] No such file or directory: '\xd4\xc5\xd3\xd4'

Note that this can be a feature too! You might have a filename that
*looks* normal but contains a character from a different language --
the \u encoding will show you the problem.

$ ls *.py
mc.py	x.py
guido-van-rossums-imac:~ guido$ python
Python 2.5.2 (release25-maint:60953, Feb 25 2008, 09:38:08)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> open('mс.py')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'm\xd1\x81.py'
>>>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list