socket script from perl -> python

Jerry Hill malaclypse2 at
Thu Feb 7 16:40:25 CET 2008

On Feb 7, 2008 9:39 AM, kettle <Josef.Robert.Novak at> wrote:
> f = open('/home/myuname/socket.wav','rb')
> audio = ""
> for line in f:
>     audio += line

I don't know anything about socket programming in python, but this bit
doesn't seem right for working on a binary file.  You should just read
all of the data into audio in one go, like this:

f = open('/home/myuname/socket.wav','rb')
audio =

There's no need to iterate over the lines in the file, since it's
quite likely that there really aren't any 'lines' in a binary file.


More information about the Python-list mailing list