title: IOError: 13, 'Permission denied' when writing to /etc/hosts via Python
body: <p>I have a Python app that I'm working on that needs to access the hosts file to append a few lines. Everything worked on my test file, but when I told the program to actually modify my hosts file in /etc/hosts I get IOError 13. From what I understand, my app doesn't have root privileges. </p>
  
  <p>My question is, how can I circumnavigate this issue? Is there a way to prompt the user for their password? Would the process be any different if I was running the app on a Windows machine?</p>
  
  <p>Here's the code in question:</p>
  
  <pre><code>f = open("/etc/hosts", "a")
  f.write("Hello Hosts File!")
  </code></pre>
  
  <p>Also, I plan on using py2app and py2exe for the final product. Would they handle the root privilege issue for me?</p>