[issue5445] codecs.StreamWriter.writelines problem when passed generator

2013-03-25 Thread Benjamin Peterson
Benjamin Peterson added the comment: Agreed. Modern consumers can use the io module. -- resolution: -> wont fix status: open -> closed ___ Python tracker ___

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2013-03-25 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 25.03.2013 23:11, Terry J. Reedy wrote: > 2. The codecs.writelines entry says "Writes the concatenated list of strings > to the stream (possibly by reusing the write() method)." For the base class, > that is overly restrictive, but I gather that Marc-An

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2013-03-25 Thread Terry J. Reedy
Terry J. Reedy added the comment: I find this to be a confusing issue. 1. The arg for .join is any iterable of strings, not just a list. (I think Daniel got that.) Since codecs.py still has "self.write(''.join(list))": a) calling the arg 'list' is doubly wrong. b) there is no iterable featu

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2010-07-08 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- versions: +Python 3.2 -Python 2.5, Python 2.6, Python 2.7, Python 3.0 ___ Python tracker ___ ___ Python-

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2009-03-10 Thread Daniel Lescohier
Daniel Lescohier added the comment: OK, I think I see where I went wrong in my perceptions of the file protocol. I thought that readlines() returned an iterator, not a list, but I see in the library reference manual on File Objects that it returns a list. I think I got confused because ther

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2009-03-10 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: On 2009-03-10 16:36, Daniel Lescohier wrote: > Daniel Lescohier added the comment: > > Let me give an example of why it's important that writelines > iteratively writes. For: > > rows = (line[:-1].split('\t') for line in in_file) > projected = (keep_fie

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2009-03-10 Thread Daniel Lescohier
Daniel Lescohier added the comment: Let me give an example of why it's important that writelines iteratively writes. For: rows = (line[:-1].split('\t') for line in in_file) projected = (keep_fields(row, 0, 3, 7) for row in rows) filtered = (row for row in projected if row[2]=='1') out_file.wr

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2009-03-10 Thread Daniel Lescohier
Daniel Lescohier added the comment: In Python's file protocol, readlines and writelines is a protocol for iterating over a file. In Python's file protocol, if one doesn't want to iterate over the file, one calls read() with no argument in order to read the whole file in, or one calls write()

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2009-03-10 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: For the common case where list is in fact a sequence of strings, the used implementation is a lot faster and more efficient than the one you propose. Note that the method doesn't pretend to support generators for the list argument, so adding support for ite

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2009-03-09 Thread Facundo Batista
Facundo Batista added the comment: When fixing this, note that the builtin name "list" should not be overwritten by the argument name. -- message_count: 1.0 -> 2.0 nosy: +facundobatista nosy_count: 1.0 -> 2.0 ___ Python tracker

[issue5445] codecs.StreamWriter.writelines problem when passed generator

2009-03-08 Thread Daniel Lescohier
New submission from Daniel Lescohier : This is the implementation of codecs.Streamwriter.writelines for all Python versions that I've checked: def writelines(self, list): """ Writes the concatenated list of strings to the stream using .write(). """ self.