a question on the new dict() keyword argument syntax
Raymond Hettinger
vze4rx4y at verizon.net
Fri Aug 1 19:36:09 EDT 2003
"Oktay Safak" <oktaysafak at ixir.com> wrote in message
news:722261f9.0308011501.48263391 at posting.google.com...
> Hi,
>
> Is there an equivalent keyword argument syntax for these cases:
>
> d1 = {1:"one"}
>
> d2 = {"1":"one"}
>
> these don't work, of course:
>
> >>> a = dict(1 = "one")
> SyntaxError: keyword can't be an expression
>
> >>> a = dict("1" = "one")
> SyntaxError: keyword can't be an expression
As you discovered, there is no equivalent. The new
syntax is limited to strings that are valid identifiers
(variable names).
Raymond Hettinger
More information about the Python-list
mailing list