dg icon indicating copy to clipboard operation
dg copied to clipboard

Incorrect interpretation of list, tuples, and dictionaries literals

Open jmi2k opened this issue 8 years ago • 3 comments

I write this:

a_list = [
    1,
    2
]

a_tuple = (
    1,
    2
)

a_dict = {
    ("a", 1),
    ("b", 2)
}

print a_list
print a_tuple
print a_dict

I expect this to evaluate to:

[1, 2]
(1, 2)
{'a': 1, 'b': 2}

But instead, only the last element is seen, and I get:

[2]
2
{'b': 2}

This bug can get very annoying if you want to nicely indent them, as you are forced to put them all in the same line.

jmi2k avatar Dec 13 '16 23:12 jmi2k

https://github.com/pyos/dg/blob/55b06a535d62900c2db239da8171b6a82eb6cb60/core/2.ast.dg#L18 Maybe this is a recommend way of write dict literals.

shizhaojingszj avatar Feb 24 '19 06:02 shizhaojingszj

Maybe this is a recommend way of write dict literals.

Maybe, but author must have clarified this in 2 years.

ceremcem avatar Feb 24 '19 06:02 ceremcem

Maybe, but author must have clarified this in 2 years.

You're awfully generous in assuming that the author is good at writing documentation...

pyos avatar Feb 24 '19 16:02 pyos