Python seems to differentiate between [x]
and list(x)
when making a list object, where x
is an iterable. Why this difference?
>>> a = [dict(a=1)]
>>> a
[{'a': 1}]
>>> a = list(dict(a=1))
>>> a
['a']
While the 1st expression seems to work as expected, the 2nd expression works more like iterating a dict this way:
>>> l = []
>>> for e in {'a': 1}:
... l.append(e)
>>> l
['a']