Message223492
One last thing, a quick & dirty solution that works today, if you don't mind accessing private internals of stdlib classes, and don't mind giving up the performance of _io for _pyio, and don't need a solution for binary files:
class MyTextIOWrapper(_pyio.TextIOWrapper):
def readrecord(self, sep):
readnl, self._readnl = self._readnl, sep
try:
return self.readline()
finally:
self._readnl = readnl
Or, if you prefer:
class MyTextIOWrapper(_pyio.TextIOWrapper):
def __init__(self, *args, separator, **kwargs):
super().__init__(*args, **kwargs)
self._readnl = separator
For binary files, there's no solution quite as simple; you need to write your own readline method by copying and pasting the one from _pyio.RawIOBase, and the modifications to use an arbitrary separator aren't quite as trivial as they look at first (at least if you want multi-byte separators). |
|
Date |
User |
Action |
Args |
2014-07-20 00:45:25 | abarnert | set | recipients:
+ abarnert, georg.brandl, rhettinger, facundobatista, amaury.forgeotdarc, ncoghlan, pitrou, benjamin.peterson, nessus42, eric.araujo, ralph.corderoy, r.david.murray, ysj.ray, Douglas.Alan, jcon |
2014-07-20 00:45:25 | abarnert | set | messageid: <1405817125.01.0.559945778129.issue1152248@psf.upfronthosting.co.za> |
2014-07-20 00:45:25 | abarnert | link | issue1152248 messages |
2014-07-20 00:45:24 | abarnert | create | |
|