
May 25, 2016
6:55 p.m.
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