[Python-ideas] Unpacking a dict

Brendan Barnwell brenbarn at brenbarn.net
Wed May 25 14:55:10 EDT 2016

On 2016-05-25 11:42, Steven D'Aprano wrote:
> If the target on the left has a colon, it is an identifier followed by
> key. The identifier can be any valid reference, including dots and []
> subscripts. The key must be a string:
> identifier:'key'
> which performs:
> identifier = mapping['key']

	Why does the key have to be a string?  I agree that the common case is 
where you want to assign to a local variable with the same name as the 
string key, but if you do allow specifying how keys map to assignment 
targets, it seems like you might as well allow non-string keys.

Brendan Barnwell
"Do not follow where the path may lead.  Go, instead, where there is no 
path, and leave a trail."
    --author unknown

More information about the Python-ideas mailing list