not logged in | [Login]
Arrays in Python - but not what you'd expect if you come from any other language.
import array
a=array.array(<typecode>,[intialiser])
a.append(<object_of_type_typecode>)
>>> a=array.array('B',[1,2,3,4,5,6,7,8,9,10])
>>> a[0]
1
>>> a[1]
2
Only a subset of CPython typecodes are currently supported.
array.array does support the buffer protocol therefore can be used as target of pyb.ADC.read_timed
or source of pyb.DAC.write_timed
.
Last edited by Jonathan Barchi, 2015-01-02 01:12:37