list object

G

Gandalf

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
 
M

member thudfoo

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

Remove the "(1)"
 
T

Terry Reedy

| > 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.
 
L

Larry Hale

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_data_types/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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,268
Messages
2,571,095
Members
48,773
Latest member
Kaybee

Latest Threads

Top