[EMAIL PROTECTED] wrote: > Is it possible to join/append 2 arrays defined with different > typecodes? > > What typecode should i use to generate the following output. > > data1 = array('h', '\0', 6) > data2 = array('L', '\0', 25) > > for i in range( 6): > data1[0] = 0xFF > data2[1] = 0x00 > data1[2] = 0x00 > data1[3] = 0x00 > data1[4] = 0x00 > data1[5] = 0x00 > > for i in range( 2): > data2[0] = 0xF0F0F0F0 > data2[1] = 0xFFFFFFFF > > Output should be... > (0xFF 0x00 0x00 0x00 0x00 0x00 0xF0F0F0F0 0xFFFFFFFF)
An arry has one typecode that applies to all its elements - so what you want can't be done. But you can use two lists and the module struct to create a string that resembles the memory layout you want. data1 = [0] * 6 data2 = [0L] * 25 struct.pack("b" * len(data1) + "l" * len(25), *(data1 + data2)) But I think you should give us more information on what you actually want to accomplish, as I've got the impression that you try to force things in awy that is not optimal. Diez -- http://mail.python.org/mailman/listinfo/python-list