Please note: This wiki is currently running in test mode after an attack on January 5 2013. All passwords were reset, so you will have to use the password recovery function to get a new password. To edit wiki pages, please log in first. See the wiki attack description page for more details. If you find problems, please report them to the pydotorg-www mailing list.

Your search query "linkto:"WorkingWithProcesses"" didn't return any results. Please change some terms and refer to HelpOnSearching for more information.
(!) Consider performing a full-text search with your search terms.

Clear message

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 # Export an environment variable
   4 os.environ["FOO"] = "BAR"
   5 
   6 # Make sure environment variable set for child processes
   7 for line in os.popen("bash -c 'env'").read().splitlines():
   8     if line.startswith("FOO="):
   9         print line
  10 
  11 # Since environment variable "FOO" is exported, and since child
  12 # processes inherit environment variables from their parents, this
  13 # works.