Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 1st, 2004, 02:18 AM
mtcarson mtcarson is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 1 mtcarson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old November 1st, 2004, 02:36 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 8
Send a message via MSN to Grim Archon
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 ***

Reply With Quote
  #3  
Old November 1st, 2004, 09:21 AM
Boki's Avatar
Boki Boki is offline
A wanna-be guru of some sort
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2004
Location: Either online or offline
Posts: 624 Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level)Boki User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 4 h 7 m 13 sec
Reputation Power: 14
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
>>>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > math module


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT