[Tutor] array of different datatypes

Steve Willoughby steve at alchemy.com
Tue Sep 23 05:16:29 CEST 2008


Dinesh B Vadhia wrote:
> I have looked (honestly!) and cannot see an array structure to allow different datatypes per column.  I need a 2 column array with column 1 = an integer and column 2 = chars, and after populating the array, sort on column 2 with column 1 sorted relatively.  


If by "array" you mean a regular Python list, the data type of
every single element may be different.  So it's just how lists
always work.

a = [[1, 'hello'],
      [2, 'world'],
      [42, 'fish'],
     ]

> Thanks!
> 
> Dinesh
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor



More information about the Tutor mailing list