How do I programmatically implement super user privileges in a script?
<p>I've written a python script. One of the functions opens a port to listen on.  To open a port to listen on I need to do it as super user.  I don't want to run the script with <code>sudo</code> or with root permissions, etc.  I saw an answer here regarding sub-process using <code>sudo</code>.  It's not a sub-process I want as far as I know. It's just a function within the application.</p>

<p>Question: How do I programmatically open a port with super user permissions?</p>

<p>You could use sudo inside your python script like this, so you don't have to run the script with sudo or as root.</p>

<pre><code>import subprocess
subprocess.call(["sudo", "cat", "/etc/shadow"])
</code></pre>

python permissions