title: Convert list of floats into buffer in Python?
body: <p>I am playing around with PortAudio and Python.</p>
  
  <pre><code>data = getData()
  stream.write( data )
  </code></pre>
  
  <p>I want my stream to play sound data, that is represented in Float32 values. Therefore I use the following function:</p>
  
  <pre><code>def getData():
      data = []
      for i in range( 0, 1024 ):
          data.append( 0.25 * math.sin( math.radians( i ) ) )
      return data
  </code></pre>
  
  <p>Unfortunately that doesn't work because <code>stream.write</code> wants a buffer object to be passed in:</p>
  
  <pre><code>TypeError: argument 2 must be string or read-only buffer, not list
  </code></pre>
  
  <p>So my question is: How can I convert my list of floats in to a buffer object?</p>