Design of Python curiosity, why so? -
say have x = [2,4,5]
. if y = list(x)
, [2,4,5]
, true tuples. bit surprising me, have expected [[2,4,5]]
in former case. have been motivation not giving list of list?
the list
builtin type takes arbitrary iterable (regardless of type) , creates new list out of it. since list
instance iterable, can used construct new list iteration.
if expect list([1,2,3])
give [[1,2,3]]
, why wouldn't expect list((1,2,3))
return [(1,2,3)]
or list(x x in range(10))
return [<generator object <genexpr> @ 0xef170>]
?
Comments
Post a Comment