Subclassing file class

Michael Hudson mwh at python.net
Wed Aug 4 08:43:26 EDT 2004


"David Vaughan" <David.Vaughan at Gifford.UK.com> writes:

> I'm using v2.3, and trying to write to text files, but with a maximum
> line length.  So, if a line is getting too long, a suitable ' '
> character is replaced by a new line.  I'm subclassing the file class,
> and, as long as I just use the write method, this works fine.  But
> "print >>" doesn't behave as I want:

You'll almost certainly be happier implementing a 'file-like object'
that does what you want than subclassing file.

Cheers,
mwh

-- 
  Every day I send overnight packages filled with rabid weasels to
  people who use frames for no good reason.
                             -- The Usenet Oracle, Oracularity #1017-1



More information about the Python-list mailing list