They are not equivalent. list() tries to iterate over its argument, making each object a separate list item, while the literal list [] just accepts exactly what it gave. For comparison:
>>> list("foo") ['f', 'o', 'o'] >>> ["foo"] ['foo']
You cannot iterate over None , hence the error. You will get the same with any indestructible argument:
>>> list(1) Traceback (most recent call last): File "<pyshell#14>", line 1, in <module> list(1) TypeError: 'int' object is not iterable
To get the equivalent of a = [None] using list() , you need to pass it iterable with a single object, for example,
a = list([None])
although this will create a list literal and then copy it, so this is not very useful in this trivial example!
source share