One possible solution is to create the flag string manually.
import sys def getFlags(): flags = ['-d', '-3', '-Q', '-Qnew', '-i', '-i', '-O', '-B', '-s', '-S', '-E', '-t', '-v', '-U', '-b', '-R'] return ' '.join({s for s, f in zip(flags, sys.flags) if f}) print getFlags()
See Python Docs for sys.flags
EDIT: the -R flag should be removed here if your python version is below 2.7.3 .
source share