On 29/11/2010 21:44, Dan Stromberg wrote:
What's the best way of reading lines of null terminated (ASCII NUL, \0) text in Python 2.x? How about for 3.x? I've been using http://stromberg.dnsalias.org/~strombrg/readline0.html with 2.x, but I'm moving some of my stuff to 3.x, and am wondering if there's a way that would obviate readline0.
You could read as binary data and then split on b"\x00". In Python 3 it's possible to specify the newline character, but I've found that it won't accept the null character as newline. I don't know why. :-( -- http://mail.python.org/mailman/listinfo/python-list