Re: Beginner question: Logs?

2005-06-03 Thread Peter Hansen
Robert Kern wrote:
 Greg Ewing wrote:
[about the from xxx import * syntax]
 Better still, don't even *mention* it to a beginner.
 They don't need to know about it. At all. Really.
 
 Well, the OP's use is precisely why from xxx import * exists: the 
 interactive prompt.

In that case (and, really, any time) Terry's solution is quite suitable 
and an excellent substitute.  Even at the interactive prompt some of the 
dangers (mostly the potential for name collisions) of from xxx import 
* are still present.

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-02 Thread Peter Hansen
Elliot Temple wrote:
 from math import *
 log10(15625)

It's always a good idea, especially when answering a beginner's 
question, to add the caution that this form (from xxx import *) has 
certain dangers** associated with it, and is widely considered poor 
style, and should really only rarely be used. (The math module is 
probably one of the few places where some people make an exception, 
however, but it's still not a good habit to get into.)

-Peter
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-02 Thread Terry Reedy
 import math
 math.log10(15625)

To find out the names of function in the math module without checking the 
docs, do

 dir(math) #same for any other module

To get more info, do

 help(math) # same for any other module with a doc string

Terry J. Reedy 



-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-02 Thread Terry Reedy

Peter Hansen [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Elliot Temple wrote:
 from math import *
 log10(15625)

 It's always a good idea, especially when answering a beginner's
 question, to add the caution that this form (from xxx import *) has
 certain dangers** associated with it, and is widely considered poor
 style, and should really only rarely be used.

Which is why I often do things like
 import math as m
 m.log...




-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-02 Thread Greg Ewing
Peter Hansen wrote:

 It's always a good idea, especially when answering a beginner's 
 question, to add the caution that this form (from xxx import *) has 
 certain dangers** associated with it, and is widely considered poor 
 style, and should really only rarely be used.

Better still, don't even *mention* it to a beginner.
They don't need to know about it. At all. Really.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,   
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-02 Thread Robert Kern
Greg Ewing wrote:
 Peter Hansen wrote:
 
It's always a good idea, especially when answering a beginner's 
question, to add the caution that this form (from xxx import *) has 
certain dangers** associated with it, and is widely considered poor 
style, and should really only rarely be used.
 
 Better still, don't even *mention* it to a beginner.
 They don't need to know about it. At all. Really.

Well, the OP's use is precisely why from xxx import * exists: the 
interactive prompt.

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Beginner question: Logs?

2005-06-01 Thread Svens
Hey everyone! I'm a math student working on a short script involving
logs. I have a function on my scientific calculator, and was wondering
if there was a similar funtion in python.

For example:

(log65536)/(log4)= 8

I've searched around a bit and haven't been able to find anything.

Thanks!

-Christian

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-01 Thread Robert Kern
Svens wrote:
 Hey everyone! I'm a math student working on a short script involving
 logs. I have a function on my scientific calculator, and was wondering
 if there was a similar funtion in python.
 
 For example:
 
 (log65536)/(log4)= 8
 
 I've searched around a bit and haven't been able to find anything.

import math

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-01 Thread Svens
Hey thanks...

Still getting an error message though.  Here's what i'm doing:
--
import math
log10(15625)
--
-It says that log10 is not defined, but it is since the module is
imported, right?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-01 Thread Robert Kern
Svens wrote:
 Hey thanks...
 
 Still getting an error message though.  Here's what i'm doing:
 --
 import math
 log10(15625)
 --
 -It says that log10 is not defined, but it is since the module is
 imported, right?

No, read the tutorial.

import math
math.log10(15625)

-- 
Robert Kern
[EMAIL PROTECTED]

In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die.
   -- Richard Harter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-01 Thread Stephen Prinster
Svens wrote:
 Hey thanks...
 
 Still getting an error message though.  Here's what i'm doing:
 --
 import math
 log10(15625)
 --
 -It says that log10 is not defined, but it is since the module is
 imported, right?
 

try this:

import math
math.log10(15625)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Beginner question: Logs?

2005-06-01 Thread Elliot Temple

On Jun 1, 2005, at 9:04 PM, Svens wrote:

 Hey thanks...

 Still getting an error message though.  Here's what i'm doing:
 --
 import math
 log10(15625)
 --
 -It says that log10 is not defined, but it is since the module is
 imported, right?

do either

import math
math.log10(15625)


from math import *
log10(15625)

from math import log10
log10(15625)




-- Elliot Temple
http://www.curi.us/


---
[This E-mail scanned for viruses by Declude Virus]

-- 
http://mail.python.org/mailman/listinfo/python-list