GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Python Wiki
  • PSF Wiki
  • Jython Wiki
  • Python Wiki
  • Archive

This view

  • Original page
  • New address

GeezerVison is showing wiki.python.org — Working with Processes

View as Markdown

Working with Processes¶

Legacy Wiki Page

This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.

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.
Previous
With Statement and Open Gl
Next
Working with Time
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.