[Python-Dev] Import and unicode: part two

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Jan 20 19:02:28 CET 2011


On Thu, Jan 20, 2011 at 11:45 AM, Andy Teijelo <ateijelo at gmail.com> wrote:
..
> but if the code said:
>
> import café
>
> then Python would look, in any platform, for a file named:
>
> caf&eacute;.py  or  caf&#233;.py  or something nicer.
>
> Something along the lines of xmlcharrefreplace.
> Just an idea.

Curiously, something like this already happens on OSX when filename is
not valid UTF-8.  For example,

>>> open(b'\xdb\xcd', 'w').close()
>>> open(b'\xdb\xcd')
<_io.TextIOWrapper name=b'\xdb\xcd' mode='r' encoding='UTF-8'>

but the actual file created is named "%DB%CD".  (Looks like URL-encoding).


More information about the Python-Dev mailing list