Python equivalent of Java Vector

Darrell Gallion darrell at dorb.com
Mon Oct 2 17:53:51 EDT 2000


From: <hoopy_frood at my-deja.com>
> 
> "Does Python have something equivalent to Java's Vector?  For instance,
> most of the time if you want to use an array you have to declare the
> size up front.  Java has a Vector class which is an array of objects
> which grows as you add things to it.
> 

See lists:

    tmp=[]
    tmp.append("value1")
    tmp.append(55)
    print len(tmp)
    print tmp[1]

Check out the docs, lists and dictionaries are very powerful.
And who needs to declare what's in the list!

--Darrell






More information about the Python-list mailing list