[Python-Dev] unicode hell/mixing str and unicode as dictionary keys (original) (raw)

Christopher Armstrong radix at twistedmatrix.com
Fri Aug 4 16:01:51 CEST 2006


On 8/4/06, Ralf Schmitt <ralf at brainbot.com> wrote:

Jean-Paul Calderone wrote: > > I like the exception that 2.5 raises. I only wish it raised by default > when using 'ascii' and u'ascii' as keys in the same dictionary. ;) Oh, > and that str and unicode did not hash like they do. ;) No problem: >>> import sys >>> reload(sys) <module 'sys' (built-in)> >>> sys.setdefaultencoding("base64") >>> "a"==u"a" Traceback (most recent call last): ... binascii.Error: Incorrect padding

Maybe this is all just a matter of choosing the right defaultencoding ? :)

Doing this is amazingly stupid. I can't believe how often I hear this suggestion. Apparently the fact that you have to "reload(sys)" to do it isn't warning enough?

-- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-dev/attachments/20060804/6f4e00fa/attachment.html



More information about the Python-Dev mailing list