unpacking vars from list of tuples

Ross rossgk at gmail.com
Thu Sep 17 15:09:18 EDT 2009


Cool - Now that would be some seriously dense, efficient code!   Will  
have to play with numpy sometime.


R.


On 17-Sep-09, at 12:25 PM, Chris Colbert wrote:

> 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