2 Apr
2014
2 Apr
'14
5:20 p.m.
On 2014-04-02, 12:40 AM, Eric Snow wrote:
(Inspired by https://mail.python.org/pipermail/python-ideas/2010-October/008532.html)
(color: c, position: p) While it looks extremely neat, there is one design flaw that is shared with JavaScript's object literals.
In JS, if you want to define a simple object, you can write it in two ways: {'spam': 'ham'} or {spam: 'ham'} But when you have a key name defined in a variable, you'll need to do key = 'spam' o = {} o[key] = 'ham' Where in Python, you'd simply write {key: 'ham'}. So for Python, I think that having unquoted keys in literals is a bad idea. Yury