Platform: OS X Mountain Lion
Python 2.7.4
I have a piece of script that needs to convert all eol characters in a string to unix style \n. I get a string supplied by Qsci.Scintilla.text() referenced to below as txt.
print 'original text: %s' % repr(unicode(txt))
print 'linesep: %s' % repr(os.linesep)
print 'fixed text: %s' % repr(unicode(txt).replace(os.linesep, '\n'))
This shows output like:
original text: u'exp.cnvs.show()\rself.sleep(1000)'
linesep: '\n'
fixed text: u'exp.cnvs.show()\rself.sleep(1000)'
All eol characters in there are reported as \r (which is correct for OS X af far as I know). Still os.linesep reports \n to be the eol character, causing the bottom statement to do nothing. The output of that statement of course should have been:
fixed text: u'exp.cnvs.show()\nself.sleep(1000)'
Does anyone know why os.linesep appears to report the wrong eol character on OSX?