Skip to content

Instantly share code, notes, and snippets.

@sunu
Last active August 29, 2015 14:24
Show Gist options
  • Save sunu/8c90b951ccd69c8ded42 to your computer and use it in GitHub Desktop.
Save sunu/8c90b951ccd69c8ded42 to your computer and use it in GitHub Desktop.
Inconsistent behavior of dict() in case of bytestring keys.
# sunu at Mission-Control in ~/gsoc/splash on git:py3 x [23:20:21]
$ python
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> key = b'key'
>>>
>>> dict1 = {}
>>> dict1[key] = key
>>> dict1
{b'key': b'key'}
>>>
>>>
>>> dict2 = dict(key=key)
>>> dict2
{'key': b'key'}
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment