Re: [Tutor] "alias" instance of logger

2007-10-05 Thread Kent Johnson
Robert Jackson wrote: > log = > logging.basicConfig(level=logging.DEBUG,filename="/home/richard/templog",filemode='w') logging.basicConfig() does not return a logger, it returns None. > Later in my program I do: > > log.info("finished step 4.") > > Python spits out this error: > Traceback (mo

Re: [Tutor] "alias" instance of logger

2007-10-05 Thread Robert Jackson
By the way, I could have SWORN that I've done this successfully in the past in another program. I am relatively certain I have used log.LEVEL() in some of my programs in the past, but I can't figure out how I did it. /r - Original Message From: Robert Jackson <[EMAIL PROTECTED]> To: t

[Tutor] "alias" instance of logger

2007-10-05 Thread Robert Jackson
I'm working with an instance of a Python logger. Some code: log = logging.basicConfig(level=logging.DEBUG,filename="/home/richard/templog",filemode='w') Later in my program I do: log.info("finished step 4.") Python spits out this error: Traceback (most recent call last): File ""

Re: [Tutor] finding square roots

2007-10-05 Thread wesley chun
oddly enough, i get different results doing it the "old-fashioned" way: $ sqrt.py using ** 0.000447034835815 using sqrt() 0.000399112701416 $ sqrt.py using ** 0.00043797492981 using sqrt() 0.000399827957153 $ sqrt.py using ** 0.00043797492981 using sqrt() 0.000402927398682 here's the code snipp

Re: [Tutor] finding square roots

2007-10-05 Thread Alan Gauld
"Eric Brunson" <[EMAIL PROTECTED]> wrote >> t = timeit.Timer( "sqrt(12)", "from math import sqrt" ) >> print t.timeit(1000) >>> 7.17679214478 > timeit.Timer("import math; math.sqrt(64)").timeit(1000) >> 0.002298138362618829 > timeit.Timer("import math; 64 ** 0.5").timeit(1000

Re: [Tutor] questions about previous emails

2007-10-05 Thread Alan Gauld
"Fangwen Lu" <[EMAIL PROTECTED]> wrote > I wonder whether there is a way for searching for previous questions > and answers so that I don't need to ask simple questions to > overload the message flows. There are at leasty 3 archives, two of which are searchable. The official archive on the Pyho

Re: [Tutor] finding square roots

2007-10-05 Thread Eric Brunson
Alan Gauld wrote: > "Eric Brunson" <[EMAIL PROTECTED]> wrote > > > import timeit > t = timeit.Timer( "12 ** .5" ) > print t.timeit(1000) > >> 2.29147315025 >> > t = timeit.Timer( "sqrt(12)", "from math import sqrt" ) > print t.timeit(1000) >

Re: [Tutor] questions about previous emails

2007-10-05 Thread Eric Brunson
Fangwen Lu wrote: > Dear all- > > I am a new-comer to [EMAIL PROTECTED] I guess a lot of my future > questions may have been asked by others already. > > As I am a new-comer, I don't have the previous emails. > > I wonder whether there is a way for searching for previous questions > and answers

Re: [Tutor] finding square roots

2007-10-05 Thread Alan Gauld
"Eric Brunson" <[EMAIL PROTECTED]> wrote > >>> import timeit > >>> t = timeit.Timer( "12 ** .5" ) > >>> print t.timeit(1000) > 2.29147315025 > >>> t = timeit.Timer( "sqrt(12)", "from math import sqrt" ) > >>> print t.timeit(1000) > 7.17679214478 > > Looks like ** is about three times fast

[Tutor] questions about previous emails

2007-10-05 Thread Fangwen Lu
Dear all- I am a new-comer to [EMAIL PROTECTED] I guess a lot of my future questions may have been asked by others already. As I am a new-comer, I don't have the previous emails. I wonder whether there is a way for searching for previous questions and answers so that I don't need to ask si

Re: [Tutor] finding square roots

2007-10-05 Thread Eric Brunson
Elaine wrote: > Does anyone know which is the more efficient way of > finding a square root in Python: > > sqrt(x) or x ** 0.5 > I dunno, let's check: >>> import timeit >>> t = timeit.Timer( "12 ** .5" ) >>> print t.timeit(1000) 2.29147315025 >>> t = timeit.Timer( "sqrt(

[Tutor] finding square roots

2007-10-05 Thread Elaine
Does anyone know which is the more efficient way of finding a square root in Python: sqrt(x) or x ** 0.5 ??? Thanks, Elaine Building a website is a piece of cake. Yahoo! Small Busin

Re: [Tutor] Controlling the number of decimal places "Representation Error"

2007-10-05 Thread Kent Johnson
Carnell, James E wrote: > Question: > Is it a bad practice to avoid 0.1 representation errors > (0.101) by just doing the following? I'm afraid I don't understand either the problem you are trying to solve or your proposed solution. Can you say more about it? Kent > > #NOTE: all th

[Tutor] Python Magazine

2007-10-05 Thread Jeff Johnson
I've just been told by the editors at Python Magazine that the first issue is out. It's all-electronic so anyone can download and read it. Let them know what you think: http://www.pythonmagazine.com/c/issue/2007/10 You can also subscribe for print + online. -- Jeff Jeff Johnson [EMAIL PRO

[Tutor] Controlling the number of decimal places "Representation Error"

2007-10-05 Thread Carnell, James E
Question: Is it a bad practice to avoid 0.1 representation errors (0.101) by just doing the following? #NOTE: all the myVariableName stuff is because Outlook keeps changing everything I type. #I need 2 decimal places (my input number shouldn't be over 255) myNum = 1 myDiv = 3 #1000

Re: [Tutor] using python to execute from Dir A in Dir B

2007-10-05 Thread Alan Gauld
Not sure what happened to the formatting here... It should be: - "Alan Gauld" <[EMAIL PROTECTED]> wrote The given example for os.system is: sts = os.system("mycmd" + " myarg") ==> p = Popen("mycmd" + " myarg", shell=True) sts = os.waitpid(p.pid, 0) To which you would need to

Re: [Tutor] another quickie

2007-10-05 Thread Alan Gauld
"max baseman" <[EMAIL PROTECTED]> wrote > do is open a text file, write to it, than save it. so far i have a > GUI with the ability to right text (nothing amazing), but i don't > know how to have it display the text from a text file any help would > be great > > from Tkinter import * > top=Tk() >

Re: [Tutor] random number generator

2007-10-05 Thread Alan Gauld
"Jim Hutchinson" <[EMAIL PROTECTED]> wrote > program that "should" work but doesn't. It generates a random number > between 1 and 2 out to 10 decimal places. Ok, Here's the problem. You are trying to compare two floating point numbers. But python stores data in binary and displays it in decimal.

Re: [Tutor] using python to execute from Dir A in Dir B

2007-10-05 Thread Alan Gauld
"Andre Walker-Loud" <[EMAIL PROTECTED]> wrote > this module.class - if someone with more experience would feel > inclined to provide an example, I would be very much appreciative. The subprocess module documentation has several examples of using both the Popen class and the call function. Th