Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91906
| From | John Gordon <gordon@panix.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: What is the difference between list() and list? |
| Date | 2015-06-02 21:49 +0000 |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Message-ID | <mkl8cv$dsi$2@reader1.panix.com> (permalink) |
| References | <3ada3275-68c9-421c-aa19-53c312c42b1f@googlegroups.com> |
In <3ada3275-68c9-421c-aa19-53c312c42b1f@googlegroups.com> fl <rxjwg98@gmail.com> writes:
> I find the following results are interesting, but I don't know the difference
> between list() and list.
'list()' invokes the list class, which creates and returns a new list.
Since you haven't passed any arguments, the list is empty.
'list' refers to the list class itself.
Here is a more in-depth example, using functions instead of classes:
def hello(name):
return 'Hello'.
If you call this function, like so:
greeting = hello()
print greeting
You will get the output 'Hello'.
But, if you just REFER to the function, instead of actually CALLING it:
greeting = hello
print greeting
You will get this output:
<function hello at 0xbb266bc4>
Because you omitted the double parentheses, you're getting the hello
function object itself, instead of the RESULT of that function.
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
What is the difference between list() and list? fl <rxjwg98@gmail.com> - 2015-06-02 14:33 -0700 Re: What is the difference between list() and list? Joel Goldstick <joel.goldstick@gmail.com> - 2015-06-02 17:38 -0400 Re: What is the difference between list() and list? "Dr. Bigcock" <dreamingforward@gmail.com> - 2015-06-02 14:40 -0700 Re: What is the difference between list() and list? John Gordon <gordon@panix.com> - 2015-06-02 21:49 +0000
csiph-web