[Tutor] Using numpy Array Capabilities
Alan Gauld
alan.gauld at btinternet.com
Mon Apr 13 09:37:59 CEST 2009
"Wayne Watson" <sierra_mtnview at sbcglobal.net> wrote
> Basically, what I would like to do is to take a list like:
>
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>
> and convert it to;
> [['0x0', '0x1', '0x2', '0x3', '0x4'], ['0x5', '0x6', '0x7', '0x8',
> '0x9']]
What is the basis of this conversion?
Why did you split it into two lists?
Why convert into hex strings?
If the original list had been:
[3, 5, 78, 21, -3, 7, 5]
What would your output look like?
> That is, it becomes a matrix of 2 rows and 5 columns. I generated the
> above from a loop in Python, and generated hex equivalents in the last
> list.
It might help to see those loops because it might
explain the reasoning behind the apparently arbitrary
decisions.
> Can numpy do this simply without resorting to loops?
Can't help there, I've never used numpy...
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list