Process list on Linux via Python
Question: How can I get running process list using Python on Linux?


Answer: IMO looking at the `/proc` filesystem is less nasty than hacking the text
output of `ps`.

    
    
    import os
    pids = [pid for pid in os.listdir('/proc') if pid.isdigit()]
    
    for pid in pids:
        try:
            print open(os.path.join('/proc', pid, 'cmdline'), 'rb').read()
        except IOError: # proc has already terminated
            continue
    

