Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old June 27th, 2008, 05:24 PM
Gandalf
Guest
 
Posts: n/a
Default list object

my manual contain chapter about lists with python. when i try to copy
paste :

li = ["a", "b", "mpilgrim", "z", "example"] (1)


it i get this errore:

"TypeError: 'list' object is not callable"

i was wondering if their is any special module I should import before
i use this function

i know i ask foolish questions it's my first day with python and i
have experience only with PHP and javascript, so please be patient

thanks
  #2  
Old June 27th, 2008, 05:24 PM
member thudfoo
Guest
 
Posts: n/a
Default Re: list object

On 5/10/08, Gandalf <goldnery@gmail.comwrote:
Quote:
my manual contain chapter about lists with python. when i try to copy
paste :
>
li = ["a", "b", "mpilgrim", "z", "example"] (1)
>
>
it i get this errore:
>
"TypeError: 'list' object is not callable"
>
i was wondering if their is any special module I should import before
i use this function
>
i know i ask foolish questions it's my first day with python and i
have experience only with PHP and javascript, so please be patient
>
thanks
>
--
http://mail.python.org/mailman/listinfo/python-list
>
Remove the "(1)"
  #3  
Old June 27th, 2008, 05:24 PM
Terry Reedy
Guest
 
Posts: n/a
Default Re: list object


"member thudfoo" <thudfoo@opensuse.uswrote in message
news:3d881a310805101047s1cc9c803wb87805e8044b514c@ mail.gmail.com...
| On 5/10/08, Gandalf <goldnery@gmail.comwrote:
| my manual contain chapter about lists with python. when i try to copy
| paste :
| >
| li = ["a", "b", "mpilgrim", "z", "example"] (1)
| >
| >
| it i get this errore:
| >
| "TypeError: 'list' object is not callable"

| Remove the "(1)"

The '(1)' was almost certainly an 'equation number' or 'line label' added
so the author could refer it in the text, like 'type line (1) into the
interpreter and... . This is a standard mathematical idiom, but sometimes
confusing when there is not enough space between the equation and the
label, and especially when the equation label *could* be part of the
equation, as with Python.




  #4  
Old June 27th, 2008, 05:24 PM
Larry Hale
Guest
 
Posts: n/a
Default Re: list object

On May 10, 12:39 pm, Gandalf <goldn...@gmail.comwrote:
Quote:
my manual contain chapter about lists with python. when i try to copy
paste :
>
li = ["a", "b", "mpilgrim", "z", "example"] (1)
>
it i get this errore:
>
"TypeError: 'list' object is not callable"
>
i was wondering if their is any special module I should import before
i use this function
>
i know i ask foolish questions it's my first day with python and i
have experience only with PHP and javascript, so please be patient
>
thanks

To expand upon what others have already mentioned, and/or to explain
what's going on...

li ==>a label for a "list" (presume the author used it as short-
hand?); trying to set it to point-to/"equal"...

["a", "b", "mpilgrim", "z", "example"] ==>THE LIST

A "list" is a mutable (changeable in-place) container object.
See e.g.: http://www.diveintopython.org/native...pes/lists.html

(1) ==>the Python interpreter will interpret this as if you're
attempting to "call" the list object (["a", "b", ...]) as if it were a
function/method


Indeed, the "(1)" is what's causing the problem, but it's -because-
the list *object* is, well, "not callable". :)

As an aside, see what "li" contains if you do:

li = ["a", "b", "mpilgrim", "z", "example"][1]

;)


Cheers!
-Larry Hale
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles