This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Cyphase
Recipients Cyphase
Date 2014-04-21.11:54:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1398081299.38.0.288058317096.issue21320@psf.upfronthosting.co.za>
In-reply-to
Content
Python 2.7.6: Affected
Python 3.2.3: Not affected

dict() allows keyword expansion using a dict() with integer keys, whereas attempting to do so with most other functions raises a TypeError with the message, "keywords must be strings". The same thing happens with collections.defaultdict(), but not collections.Counter() or collections.OrderedDict, presumably because they override dict.__init__().

>>> old_dict = {'a': 1, 2: 'b'}
>>> old_dict
{'a': 1, 2: 'b'}
>>> other_dict = {'c': 3, 4: 'd'}
>>> other_dict
>>> new_dict = dict(old_dict, **other_dict)
>>> new_dict
{'a': 1, 2: 'b', 4: 'd', 'c': 3}

I feel like this must be known, but I didn't find anything with a search.
History
Date User Action Args
2014-04-21 11:54:59Cyphasesetrecipients: + Cyphase
2014-04-21 11:54:59Cyphasesetmessageid: <1398081299.38.0.288058317096.issue21320@psf.upfronthosting.co.za>
2014-04-21 11:54:59Cyphaselinkissue21320 messages
2014-04-21 11:54:58Cyphasecreate