When creating lists in python, the two easy methods are list(arg)
and [args]
. However, only one of these allows multiple arguments, even though both result in an object of type list
. Example:
>>> a=list('foo')
>>> type(a)
<class 'list'>
>>> a=list('foo','bar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list() takes at most 1 argument (2 given)
>>> a=['foo','bar']
>>> a
['foo', 'bar']
>>> type(a)
<class 'list'>
Why is only the implicit call to list()
via brackets valid?