i need help on builtin function math

Alex Martelli aleaxit at yahoo.com
Thu Mar 29 03:56:51 EST 2001


"Marcus Konermann" <m_konermann at gmx.de> wrote in message
news:mailman.985822299.17200.python-list at python.org...
> hello !
>
> i want to use the sqrt() function of the builtin funtion math in that
> kind:
>
> import math
> ...
> a=0
> a=sqrt(whatever)
>
> and than a NameError: sqrt occured and i don´t know why ? Is it
> depending on the OS (i use Windows98 and the pywin
> editor). Other functions, like pow(), from the math module are working.

There is a *built-in* function pow, which is not the same
as math.pow, and is no doubt what IS being executed here:

>>> pow
<built-in function pow>
>>> import math
>>> math.pow
<built-in function pow>
>>> pow is math.pow
0
>>> math.pow(2, 35000)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: math range error
>>> pow(2, 35000)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: integer exponentiation
>>>


> Can anyone help me with my problem ?

Either:
    import math
    a=math.sqrt(whatever)
or:
    from math import sqrt
    a=sqrt(whatever)


Alex






More information about the Python-list mailing list