WorkingWithProcesses

This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

These are just some notes about working with processes in Python.

The module of interest is os. (os module documentation)

Environment variables are accessed through a dictionary, os.environ.

Processes are created with os.popen, described in os 6.1.2.

   1 import os
   2 
   3 
   4 os.environ["FOO"] = "BAR"
   5 
   6 
   7 for line in os.popen("bash -c 'env'").read().splitlines():
   8     if line.startswith("FOO="):
   9         print line
  10 
  11 
  12 
  13