467,119 Members | 1,187 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,119 developers. It's quick & easy.

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
Jun 27 '08 #1
  • viewed: 1418
Share:
3 Replies
On 5/10/08, Gandalf <go******@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"

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)"
Jun 27 '08 #2

"member thudfoo" <th*****@opensuse.uswrote in message
news:3d******************************************@ mail.gmail.com...
| On 5/10/08, Gandalf <go******@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.


Jun 27 '08 #3
On May 10, 12:39 pm, Gandalf <goldn...@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"

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
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by Fuzzyman | last post: by
9 posts views Thread by Jess Austin | last post: by
2 posts views Thread by Aaron | last post: by
6 posts views Thread by jena | last post: by
4 posts views Thread by Cedric Rogers | last post: by
9 posts views Thread by Stephan Steiner | last post: by
7 posts views Thread by =?Utf-8?B?Sm9lbCBNZXJr?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.