[Tutor] Arrays and tuples

antonmuhin на rambler.ru antonmuhin на rambler.ru
Mon Jan 27 12:13:01 2003


Hello Deirdre,

Monday, January 27, 2003, 6:32:44 PM, you wrote:

DH> Hi there, 
DH> Thanks for all the advice the last time. Worked out great!

DH> I want to now put my 3 integer values into an array but it will not let me do

DH> data[0] = int(x2string)
DH> data[1] = int(y2string).... etc

DH> instead I have to
DH> data = (int(x2string), int(y2string), int(z2string))

DH> and this is only a tuple in which the size cannot be changed.

DH> Can you create an array that you can append values to it. You cannot append vales to a tuple - its size is static.

As I understand your problem, you forgot to define a variable. The
code below should work:

myArray = {} # Define an array
myArray[0] = int("123")
....

BTW, it's not an array, but a dictionary. If speed is crucial for your
application, glance at arrays from Numeric.


-- 
Best regards,
 anton                            mailto:antonmuhin@rambler.ru