On May 10, 12:39 pm, Gandalf <[EMAIL PROTECTED]> wrote: > 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 -- http://mail.python.org/mailman/listinfo/python-list