What is the difference between list() and list?

Joel Goldstick joel.goldstick at gmail.com
Tue Jun 2 17:38:19 EDT 2015


On Tue, Jun 2, 2015 at 5:33 PM, fl <rxjwg98 at gmail.com> wrote:
> Hi,
>
> I find the following results are interesting, but I don't know the difference
> between list() and list.
>
>
>
>
>
>
>>>> nums=list()
>>>> nums
> []
>>>> xx=list
>>>> xx
> <type 'list'>
>>>> nums
> []
>>>> print(xx)
> <type 'list'>
>>>> print(nums)
> []
>>>>
>
>
>
> Could you tell me that?

list is the name of a built-in function that returns a list object
when you set xx = list, you are giving that function a new name -- 'xx'
when you invoke the function:  xx() or list() it returns a list
>
> Thanks,
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com



More information about the Python-list mailing list