On Wed, Jan 19, 2011 at 09:02:17PM -0800, Glenn Linderman wrote: > 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. > You're missing a piece here. If you mandate ascii you can convert to a unicode name using "import as" because python knows that it has ascii text from the filesystem when it converts it to an abstract unicode string that you've specified in the program text. You cannot go the other way because python lacks the information (the encoding of the filename on the filesystem) to do the transformation.
> 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. > Does my demonstration that you can't do that mean that it's no longer acceptable? :-) /me guesses that the relative merits of being forced to write portable code vs convenience of writing a module name in your native script still has a different balance than in mine, thus the smiley :-) -Toshio
pgpVg5DKpRDXA.pgp
Description: PGP signature
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com