[Tutor] Python equivalent of Java Vecor?

R. A. griff@netdoor.com
Mon, 02 Oct 2000 16:13:42 -0500

I've been asked another Python question that's over my head, so I asked
the querant to re-phrase it a bit so I could ask y'all.  Here is his

"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.

"Just curiousity on my part really, but if you are serious about using
Python productively, you probably need to answer that.  In Java, for
instance, if I want an array of String I say "String tmp[]=new
String[5]" and I have an array of Strings with 5 slots.  If I didn't
know how many Strings I was going to have though, I could say "Vector
tmp=new Vector()" then every time I wanted to add a String, say "String
tmpvalue" I could say "tmp.addElement(tmpvalue)".  Then, I could say
"tmp.size()" to see how many elements were in the Vector, and I can even
to a "tmp.elementAt(int x)" to retrieve a value.  So, I think the
terminology would be that Java supports dynamic arrays of objects.  I
was wondering if Python had the equivalent."

Rob Andrews
GIT/P/TW d---(++) s++:s a? C+++++ U$>+++ P+ L+>++++ E@ W++ N++ o? K- w$
?O ?M ?V PS+++ PE Y+@ PGP- t+@ 5 X@ R+ tv+ b+++ DI+@ D+ Q3A++ e++* h* r
y++* UF+++