Python Library Question

Jeff Shannon jeff at
Wed Aug 22 21:21:41 CEST 2001

Kurt Jansen wrote:

> I am new to Python, and am trying to implement a Web site using Python
> for my CGI scripts.  I am having trouble using any of the functions in
> the Python Library on my Web hosting provider's system.  For instance,
> if I try to use the math functions, I get the following errors:
> west38:~$ python
> Python 1.4 (Dec 18 1996) [GCC]
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import math
> >>> x=2
> >>> y=exp(x)
> Traceback (innermost last):
> File "<stdin>", line 1, in ?
> NameError: exp
> >>>
> Am I doing something wrong, or is the Python Library not loaded on my
> hosting provider's system?
> Kurt Jansen

When you are using functions (or other attributes) from an imported
module, you have to prepend the module name--in effect, you're telling the
interpreter *where* to find that function.  So try:

>>> import math
>>> x = 2
>>> y = math.exp(2)
>>> y

Jeff Shannon
Credit International

More information about the Python-list mailing list