unpacking vars from list of tuples

Chris Colbert sccolbert at gmail.com
Thu Sep 17 18:25:41 CEST 2009


if you have numpy installed:


ln[12]: import numpy as np
In [13]: k = np.array([('a', 'bob', 'c'), ('p', 'joe', 'd'), ('x',
'mary', 'z')])

In [14]: k
Out[14]:
array([['a', 'bob', 'c'],
       ['p', 'joe', 'd'],
       ['x', 'mary', 'z']],
      dtype='|S4')

In [15]: k[:,1]
Out[15]:
array(['bob', 'joe', 'mary'],
      dtype='|S4')



More information about the Python-list mailing list