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
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 projecte
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
Daniel Lescohier added the comment:
I had other code to check scale, but you are right, I should use
quantize. There is certainly a lot to absorb in the IBM decimal
specification. I really appreciate you pointing me to quantize and
Inexact. I guess I inadvertently used the issue tracker for
New submission from Daniel Lescohier :
I would like to get the decimal precision of decimal.Decimal objects
(for my application, in order to validate whether a Decimal value will
fit in the defined decimal precision of a database field). The way I
found to get it was with:
precision = len
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