Creating a list in Python- something sneaky going on?

Posted by GlenCrawford on Stack Overflow See other posts from Stack Overflow or by GlenCrawford
Published on 2010-04-29T10:56:48Z Indexed on 2010/04/29 11:07 UTC
Read the original article Hit count: 302

Filed under:
|
|

Apologies if this doesn't make any sense, I'm very new to Python!

From testing in an interpreter, I can see that list() and [] both produce an empty list:

>>> list()
[]
>>> []
[]

From what I've learned so far, the only way to create an object is to call its constructor (__init__), but I don't see this happening when I just type []. So by executing [], is Python then mapping that to a call to list()?

© Stack Overflow or respective owner

Related posts about python

Related posts about lists