|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
math module
New to python,
I understand that there should be a built in math module. If it is functional I should be able to; >>>pi 3.1315...... but I get; NameError: name 'pi' is not defined I can do; from math import pi but I should not have to do this. Anybody know what is going on? Thanks |
|
#2
|
||||
|
||||
|
Just like the sys module the math module is always available for importing.
To avoid name space pollution for one thing you still need to explicitly do the import.grimey
__________________
*** Experimental Python Markup CGI V2 *** |
|
#3
|
||||
|
||||
|
Consider the following:
Code:
>>> import math >>> pi Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'pi' is not defined >>> math.pi 3.1415926535897931 >>> from math import * >>> pi 3.1415926535897931 >>> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > math module |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|