a question on the new dict() keyword argument syntax

O

Oktay Safak

Hi,

Is there an equivalent keyword argument syntax for these cases:

d1 = {1:"one"}

d2 = {"1":"one"}

these don't work, of course:
SyntaxError: keyword can't be an expression
SyntaxError: keyword can't be an expression

Just curious...
 
R

Raymond Hettinger

Oktay Safak said:
Hi,

Is there an equivalent keyword argument syntax for these cases:

d1 = {1:"one"}

d2 = {"1":"one"}

these don't work, of course:

SyntaxError: keyword can't be an expression

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
 
O

Oktay Safak

Hi,
As you discovered, there is no equivalent. The new
syntax is limited to strings that are valid identifiers
(variable names).


Raymond Hettinger

Thanks :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top