open administrator command prompt using python

import os
import sys
import as shell
ASADMIN = 'asadmin'

if sys.argv[-1] != ASADMIN:
    script = os.path.abspath(sys.argv[0])
    params = ' '.join([script] + sys.argv[1:] + [ASADMIN])
    shell.ShellExecuteEx(lpVerb='runas', lpFile=sys.executable, lpParameters=params)

Here is what the above code is Doing:
1. It checks if the last argument is ASADMIN. If it is, it runs the script.
2. If the last argument is not ASADMIN, it builds a new command line with sys.executable (python.exe) as the program to run.
3. It appends ASADMIN to the end of the command line.
4. It executes the command line using the runas verb.
5. If the command is successfully started, the original script exits.