473,395 Members | 2,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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
3 1648
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: oom | last post by:
I am a bit of a newbie when it comes to python, when working with lists today I noticed some very odd behaviour, any suggestions welcome: Python 2.2.3 (#1, Nov 6 2003, 14:12:38) on linux2...
23
by: Fuzzyman | last post by:
Pythons internal 'pointers' system is certainly causing me a few headaches..... When I want to copy the contents of a variable I find it impossible to know whether I've copied the contents *or*...
9
by: Jess Austin | last post by:
hi, I like the way that Python does lists, and I love the way it does iterators. But I've decided I don't like what it does with iterators of lists. Lists are supposed to be mutable sequences,...
2
by: Aaron | last post by:
I have a data sructure setup and I populate it in a loop like so: y=0 while X: DS.name = "ASDF" DS.ID = 1234 list = DS; y = y + 1
6
by: jena | last post by:
hello, when i create list of lambdas: l=] then l() returns 'C', i think, it should be 'A' my workaround is to define helper class with __call__ method: class X: def __init__(self,s): self.s=s...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
4
by: Cedric Rogers | last post by:
I wasn't sure if I could do this. I believe I am stretching the capability of what generics can do for me but here goes. I have a generic delegate defined as public delegate bool...
10
by: AZRebelCowgirl73 | last post by:
This is what I have so far: My program! import java.util.*; import java.lang.*; import java.io.*; import ch06.lists.*; public class UIandDB {
9
by: Stephan Steiner | last post by:
Hi I seem to have a bit of trouble understanding one bit of how generics work: In C#, every class automatically derives from object, and inherits a bunch of properties (i.e. ToString()). Thus,...
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.