python list/array question...

Alex Martelli aleax at mac.com
Wed Jul 5 11:17:30 EDT 2006


Sybren Stuvel <sybrenUSE at YOURthirdtower.com.imagination> wrote:

> Bruno Desthuilliers enlightened us with:
> > Python has lists (which AFAIK really are arrays not linked lists,
> > but they are called 'lists').
> 
> An array is generally understood as a list of items of the same type,
> hence Python lists aren't arrays.

Hmmm...

>>> x = Numeric.array([23, 4.5, 'zap!'], 'O')
>>> type(x)
<type 'array'>
>>> x
array([23 , 4.5 , zap! ],'O')

Should I think that an array (Numeric.array) is not an array?  After all
it can hold just the same variety of item types as a Python list.  Or is
it more useful to say that the "type" (which all the items have in
common) is "Python object"?  (After all, 'object' IS what the typecode
letter 'O' stands for).  I definitely like to think of Numeric.array's
as arrays, and I think it's both proper and useful to do so...


Alex



More information about the Python-list mailing list