math module

Kalle Svensson kalle at
Thu Jan 10 05:34:54 EST 2002

[gombosk at]
> I have a problem with math module:
> I import math module, because to call exp(x) or sqrt(x) does not work.
> Do I need anything else to do?
> >>> import math
> >>> exp(10)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> NameError: name 'exp' is not defined

To access the names in an imported module, you must prepend the module name:
>>> import math
>>> math.exp(10)

Read more about modules, namespaces and import on

Kalle Svensson (kalle at - Laziness, impatience, hubris: Pick two!
English:  Svenska:
Stuff: ["" % x for x in "gnu debian python emacs".split()]

More information about the Python-list mailing list