This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, georg.brandl, skip.montanaro, techtonik
Date 2008-07-24.14:20:16
SpamBayes Score 0.040136125
Marked as misclassified No
Message-id <1216909218.77.0.531823284376.issue3359@psf.upfronthosting.co.za>
In-reply-to
Content
> does it mean that if newline='\r\n' is specified all single '\n'
> characters are returned inline?
Yes.

Let's take a file with mixed newlines:
>>> io.open("c:/temp/t", "rb").read()
'a\rb\r\nc\nd\n'

rb mode splits only on '\r\n' (I'm on Windows)
>>> io.open("c:/temp/t", "rb").readlines()
['a\rb\r\n', 'c\n', 'd\n']

rU mode splits on every newline, and converts everything to \n
>>> io.open("c:/temp/t", "rU").readlines()
[u'a\n', u'b\n', u'c\n', u'd\n']

newline='' splits like rU, but does not translate newlines:
>>> io.open("c:/temp/t", newline='').readlines()
[u'a\r', u'b\r\n', u'c\n', u'd\n']

newline='\r\n' only splits on the specified string:
>>> io.open("c:/temp/t", newline='\r\n').readlines()
[u'a\rb\r\n', u'c\nd\n']
History
Date User Action Args
2008-07-24 14:20:19amaury.forgeotdarcsetspambayes_score: 0.0401361 -> 0.040136125
recipients: + amaury.forgeotdarc, skip.montanaro, georg.brandl, techtonik
2008-07-24 14:20:18amaury.forgeotdarcsetspambayes_score: 0.0401361 -> 0.0401361
messageid: <1216909218.77.0.531823284376.issue3359@psf.upfronthosting.co.za>
2008-07-24 14:20:17amaury.forgeotdarclinkissue3359 messages
2008-07-24 14:20:17amaury.forgeotdarccreate