Silly Question

Gerhard Häring gerhard.haering at
Tue Mar 11 14:38:16 CET 2003

Clint Bailey <Photoman6x6 at> wrote:
> I've been studying Magnus Lie Hetland's book, Practical Python, for some 
> time now. For some time something has struck me. Is there such an object as 
> an ARRAY in the Python language.

An array is a low-level construct that you hardly ever need. So it's hidden
away in the array *module*.

What you most probably want is a list type, that can hold an arbitrary number
of elements. This one is part of core Python. You use it like this:

l1 = [3, 4, 5]  # A list of integers
l2 = ["s1", "s2"] # A list of strings
l_misc = [3, 5.0, "asdfsdf"] # A list of misc. stuff

print l1[0]     # print first list element
l1.append(6)    # append another element to the list

etc. Have a look at the methods lists support in order to learn how to use
them. They're a little hard to find, because they're hidden here:

Uhm. Better read your tutorial than this. I hardly understand it myself ;-)

-- Gerhard

More information about the Python-list mailing list