hi John, >>> In the previous language I used, >>> when reading a line by readline, the EOL character was removed. > > Very interesting; how did you distinguish between EOF and an empty line? > Did you need to call an isEOF() method before each read? Yes indeed, and I admit it needs some more coding ;-) > >>> >>> Now I'm reading a text-file with CR+LF at the end of each line, >>> Datafile = open(filename,'r') line = Datafile.readline() >>> >>> now this gives an extra empty line >>> print line >>> >>> and what I expect that should be correct, remove CR+LF, >>> gives me one character too much removed >>> print line[,-2] > > Stef, that would give you a syntax error. I presume that you meant to > type line[:-2] Yes, sorry. > >>> >>> while this gives what I need ??? >>> print line[,-1] >>> >>> Is it correct that the 2 characters CR+LF are converted to 1 character ? > > In text mode (the default), whatever is the line ending on your platform > is converted to a single "newline" '\n' which is the same as LF. Aha, that was the answer I was looking for.
<snip> thanks for the splendid explanation John, cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list