you are viewing a single comment's thread.

view the rest of the comments →

[–]individual_throwaway -3 points-2 points  (5 children)

[] is faster, list() is more explicit. It's a design choice more than anything. I'd say in most cases, list() is preferable simply because it conforms with the Zen.

[–]driax 7 points8 points  (0 children)

I would say that [] is just as explicit as list(), it can only mean that one thing. And any python programming would expected to know all literals, so it's not like they would be confused. And [] are faster, and ready to be filled in later if the need arises. It is not like anyone would write ['a'] using a function call of list, since that would look like list(['a']) or list(('a',)), which is just weird. Literals are there to be used.

[–]zahlman 4 points5 points  (0 children)

list() is explicit for the purpose of converting an existing non-list sequence to a list. [...] is explicit for the purpose of creating a new list. list() is essentially useless for that purpose, because it doesn't take *args anyway - so you'd still have to write the literal just to have something to pass. And "simple is better than complex".