If you are working on Unix, you can analyze the output:
import os print os.popen("ps -p %d -oargs=" % os.getpid()).read().strip()
play with getpid() and getppid() (for the parent). For a portable solution, you need external libraries such as psutil :
import psutil, os p = psutil.Process(os.getppid()) print p.name
source share