[BangPypers] array in python

Roshan Mathews rmathews at gmail.com
Thu Oct 8 08:18:22 CEST 2009


On Thu, Oct 8, 2009 at 6:15 AM, harshal jadhav <jadhav.harshal at gmail.com> wrote:
> I am using python language for GNU Radio. For this i have a sampled signal.
> The signal is a sine wave. I have to trap each sample of this sine wave in
> an array.
> Is it possible to capture the samples of the sine wave in  an array in
> python?
>
You can use lists, and there is an array module too.

>>> import array
>>> help(array)
Help on built-in module array:

NAME
    array

FILE
    (built-in)

DESCRIPTION
    This module defines an object type which can efficiently represent
    an array of basic values: characters, integers, floating point
    numbers.  Arrays are sequence types and behave very much like lists,
    except that the type of objects stored in them is constrained.  The
    type is specified at object creation time by using a type code, which
    is a single character.  The following type codes are defined:

        Type code   C Type             Minimum size in bytes
        'c'         character          1
        'b'         signed integer     1
        'B'         unsigned integer   1
        'u'         Unicode character  2
        'h'         signed integer     2
        'H'         unsigned integer   2
        'i'         signed integer     2
        'I'         unsigned integer   2
        'l'         signed integer     4
        'L'         unsigned integer   4
        'f'         floating point     4
        'd'         floating point     8

    The constructor is:

    array(typecode [, initializer]) -- create a new array


More information about the BangPypers mailing list