title: Prevent a file from being opened
body: <p>I am writing a Python logger script which writes to a CSV file in the following manner:</p>
  
  <ol>
  <li>Open the file</li>
  <li>Append data</li>
  <li>Close the file (I think this is necessary to save the changes, to be safe after every logging routine.)</li>
  </ol>
  
  <p><strong>PROBLEM</strong>:<br>
  The file is very much accessible through Windows Explorer (I'm using XP). If the file is opened in Excel, access to it is locked by Excel. When the script tries to append data, obviously it fails, then it aborts altogether.</p>
  
  <p><strong>OBJECTIVE:</strong><br>
  Is there a way to lock a file using Python so that any access to it remains exclusive to the script? Or perhaps my methodology is poor in the first place?</p>