title: How to write native newline character to a file descriptor in Python?
body: <p>The <code>os.write</code> function can be used to writes bytes into a <em>file descriptor</em> (not file object). If I execute <em><code>os.write(fd, '\n')</code></em>, only the LF character will be written into the file, even on Windows. I would like to have CRLF in the file on Windows and only LF in Linux.<br>
  What is the best way to achieve this?</p>
  
  <p>I'm using Python 2.6, but I'm also wondering if Python 3 has a different solution.</p>