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):
   File "<stdin>", line 1, in <module>
   File "/exp/lib/python2.5/encodings/base64_codec.py", line 42, in 
base64_decode
     output = base64.decodestring(input)
   File "/exp/lib/python2.5/base64.py", line 321, in decodestring
     return binascii.a2b_base64(s)
binascii.Error: Incorrect padding
 >>> "a"=="a"
True
 >>> d={u"a":1, "a":1}
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/exp/lib/python2.5/encodings/base64_codec.py", line 42, in 
base64_decode
     output = base64.decodestring(input)
   File "/exp/lib/python2.5/base64.py", line 321, in decodestring
     return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

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


BTW, python 2.4 also suppresses this exception (when instantiating the 
dictionary)

Does python 2.4 catch any exception when comparing keys (which are not 
basestrings) in dictionaries?


- Ralf

_______________________________________________
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

Reply via email to