
21 Jun
2007
21 Jun
'07
7:07 p.m.
El dj 21 de 06 del 2007 a les 06:24 -0700, en/na Michael McNeil Forbes va escriure:
key_array = empty(len(keys),dtype=tuple) key_array[:] = keys[:]
the later two statements can also be written as:
key_array = array(keys, dtype=tuple)
These are not equivalent:
keys = [('a',1),('b',2)] key_array = array(keys, dtype=tuple) key_array
array([[a, 1], [b, 2]], dtype=object)
key_array = empty(len(keys),dtype=tuple) key_array[:] = keys[:] key_array
array([('a', 1), ('b', 2)], dtype=object)
Ops. You are right. I think I was fooled by the 'dtype=tuple' argument which is in fact equivalent to 'dtype=object'.
--
Francesc Altet | Be careful about using the following code --
Carabos Coop. V. | I've only proven that it works,
www.carabos.com | I haven't tested it. -- Donald Knuth