[Python-Dev] Import and unicode: part two

Glenn Linderman v+python at g.nevcal.com
Thu Jan 20 06:02:17 CET 2011

On 1/19/2011 8:39 PM, Toshio Kuratomi wrote:
> use this::
>     import cafe as café
> When you do things this way you do not have to translate between unknown
> encodings into unicode.  Everything is within python source where you have
> a defined encoding.

This is a great way of converting non-portable module names, if the 
module ever leaves the bounds of its computer, and runs into problems there.

It may be that the best practices for writing platform portable modules 
should include
* ASCII module filenames
* Code that can handle 16 or 32 bit Unicode
* and likely some other things.

But for local code, having to think up an ASCII name for a module rather 
than use the obvious native-language name, is just brain-burden when 
creating the code.

Your demonstration of such an easy solution to the concerns you raise 
convinces me more than ever that it is acceptable to allow non-ASCII 
module names.  For those programmers in a single locale environment, 
it'll just work.  And for those not in a single locale environment, 
there is your above simple solution to achieve portability without 
changing large numbers of lines of code.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110119/a64588dc/attachment.html>

More information about the Python-Dev mailing list