[Twisted-Python] Re: ftpClient.py, retrieveFile, and line ending issues

Michael Hudson mwh at python.net
Wed Dec 7 04:41:39 EST 2005

Itamar Shtull-Trauring <itamar at itamarst.org> writes:

> On Tue, 2005-12-06 at 16:41 -0600, Keith.Gunderson at act.org wrote:
>> class FileWriterProtocol(Protocol):
>>     def __init__(self, filename):
>>         self.file = open(filename, 'w')
> You probably want open(filename, "wb"), which implies binary mode. On
> Unix this does nothing,

Actually, this is not quite true!

>>> import array
>>> open('foo', 'w').write(array.array('b', [0]))
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: argument 1 must be string or read-only character buffer, not array.array
>>> open('foo', 'wb').write(array.array('b', [0]))

> on Windows it keeps Windows from screwing with your data line
> endings.

This is still true.

pedantically-ly y'rs

  If you're talking "useful", I'm not your bot.
                                            -- Tim Peters, 08 Nov 2001

More information about the Twisted-Python mailing list