Using the Python Standard Library

From IronPython Cookbook

Revision as of 11:46, 14 July 2009 by MichaelFoord (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)

The Python Standard Library is a rich set of libraries (modules and packages) for tackling just about every programming task. They have earned Python the reputation of coming with batteries included.

The Microsoft distribution of IronPython doesn't include the Python standard library.

However, the IronPython team has put a lot of effort into making sure that as much of the standard library as possible works.

You can obtain the Python standard library by downloading the appropriate version of Python:

Alternatively, FePy comes with the Python standard library (including some patches for additional compatibility).

Having obtained the standard library, you need to give your IronPython programs access to it. There are three ways of doing this:

  1. Setup an IRONPYTHONPATH environment variable that points to the standard library directory.
  2. Manually add the path to the import search path
  3. Add the path to the import search path in, which will be imported every time ipy.exe is run.

You add to the import search path with code like:

import sys

Speaking of, if you don't replace the one in the Python standard library, the default one will overwrite the built-in help function which you will want when running the interactive interpreter.

Back to Contents.