Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Terry Carroll
On Thu, 4 Sep 2008, Robert Berman wrote: > Time to do some reading about regex. And here I thought I was slick > working with lists and strings. You shouldn't need a regexp for this. An easy way to count the trailing zeros is: - convert the number to a string; - make a copy, stripping off the

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Terry Carroll
On Thu, 4 Sep 2008, Robert Berman wrote: > "It can easily be seen that 6! = 720 and has exactly one > trailing zero. What is the lowest integer, x, such that x! has 7^20 > trailing zeros?" > > It does not, on the surface, appear to be a frontal lobe breaker. Design > an algorithm to build factori

[Tutor] Exit from a Program While in IDLE

2008-09-04 Thread Wayne Watson
Title: Signature.html It seems liking quitting, exiting, or stopping a program is a bit controversial. I've tried using sys.exit(0) while debugging a program in IDLE, but it asks if I really want to exit. I just want a no-fuss, no-muss way of exiting the code in the same fashion that when I get

[Tutor] Calling Python Programs from Word, pdfs, etc

2008-09-04 Thread Jim Morcombe
I am thinking about some long term teaching aids, so I'm simply interested in whether these things can be done. I don't need to know how yet. 1. Is it possible to invoke a Python Program from some kind of link in a Word document, similar to the way a Java Applet is run from a Web Page. Obv

Re: [Tutor] how do you make this a better code?

2008-09-04 Thread Kent Johnson
On Thu, Sep 4, 2008 at 9:00 PM, Roy Khristopher Bayot <[EMAIL PROTECTED]> wrote: > class CamHandle(object): > def __init__(self): > import os > w = os.system('gphoto2 --auto-detect > CamHandleLog.txt') > test = os.system('gphoto2 --capture-image >> CamHandleLog.txt') >

Re: [Tutor] how do you make this a better code?

2008-09-04 Thread Marc Tompkins
On Thu, Sep 4, 2008 at 6:00 PM, Roy Khristopher Bayot <[EMAIL PROTECTED]>wrote: > Correct me if I am wrong but each "import os" statement only exists in each > method. Is there a way to only import the os module once and use it in each > method? > Move it to the top of the file, outside of the

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
Chris, Thank you very much for this. It is very helpful. I will check my answer against yours in the morning. Robert Chris Fuller wrote: I spent the day mulling over this problem, and then implemented my solution when I got home. This is for the easier problem of 7**8 zeros: On my linux

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Chris Fuller
I spent the day mulling over this problem, and then implemented my solution when I got home. This is for the easier problem of 7**8 zeros: On my linux box, running something around 2 GHz, my script runs for about two minutes and the answer is 23059225. You can verify your code to that. I ch

[Tutor] how do you make this a better code?

2008-09-04 Thread Roy Khristopher Bayot
Hi. Good day. I am new to Python but I have had experience with C/C++ and Matlab. I've been reading How to Think Like a Computer Scientist and skimmed Core Python to learn. Now I havent done the exercises because I wanted to get down to the project I'm doing in my spare time. The project involves t

Re: [Tutor] Help with checking for a data type

2008-09-04 Thread Spencer Parker
Those worked for me...thanks again!!! On Thu, Sep 4, 2008 at 3:26 PM, Kent Johnson <[EMAIL PROTECTED]> wrote: > On Thu, Sep 4, 2008 at 4:56 PM, Spencer Parker <[EMAIL PROTECTED]> > wrote: > > I have a script that is taking a directory list, the script then splits > the > > name up by the hyphens

Re: [Tutor] Help with checking for a data type

2008-09-04 Thread Kent Johnson
On Thu, Sep 4, 2008 at 4:56 PM, Spencer Parker <[EMAIL PROTECTED]> wrote: > I have a script that is taking a directory list, the script then splits the > name up by the hyphens in the name. The first part of the name should be a > number, but it isn't always a number. Is there a way to say: if it

Re: [Tutor] Help with checking for a data type

2008-09-04 Thread christopher . henk
try and convert the first value in the split list to a int (or float), if that works then post the value. if it throws an exception (ValueError) then catch that and pass, or do whatever else needs doing with the listing. def postData(inputData): fields=inputData.split("-") try: n

[Tutor] Help with checking for a data type

2008-09-04 Thread Spencer Parker
I have a script that is taking a directory list, the script then splits the name up by the hyphens in the name. The first part of the name should be a number, but it isn't always a number. Is there a way to say: if its a number then post this dataif not discard? -- Spencer Parker __

Re: [Tutor] Message 'list' object has no attribute 'strptime ?

2008-09-04 Thread christopher . henk
It looks to me that your variable: time = in_time.split(":") is hiding the time module. Chris Wayne Watson <[EMAIL PROTECTED]> Sent by: [EMAIL PROTECTED] 09/04/2008 04:05 PM To "tutor@python.org" cc Subject Re: [Tutor] Message 'list' object has no attribute 'strptime ? Further info

Re: [Tutor] Message 'list' object has no attribute 'strptime ?

2008-09-04 Thread Kent Johnson
On Thu, Sep 4, 2008 at 4:05 PM, Wayne Watson <[EMAIL PROTECTED]> wrote: > Further info. If I put > y = time.strptime("11 01 05", "%H %M %S") > both in the function and in the main body. Only the line above in the > function produces an error message. > > Here's a simple program that creates the

Re: [Tutor] Python and HSQL

2008-09-04 Thread Kent Johnson
On Thu, Sep 4, 2008 at 3:00 PM, Derek Croxton <[EMAIL PROTECTED]> wrote: > Is there a way to connect to an HSQL database via Python? After some > googling, the only way I can find is to use jython and connect via jdbc. > I don't want to use jython, so I'm hoping there is another way. HSQL can ta

Re: [Tutor] Message 'list' object has no attribute 'strptime ?

2008-09-04 Thread greg whittier
On Thu, Sep 4, 2008 at 4:05 PM, Wayne Watson <[EMAIL PROTECTED]>wrote: > Further info. If I put > y = time.strptime("11 01 05", "%H %M %S") > both in the function and in the main body. Only the line above in the > function produces an error message. > > Here's a simple program that creates th

Re: [Tutor] Message 'list' object has no attribute 'strptime ?

2008-09-04 Thread Wayne Watson
Title: Signature.html Further info. If I put     y = time.strptime("11 01 05", "%H %M %S") both in the function and in the main body. Only the line above in the function produces an error message. Here's a simple program that creates the problem. import datetime def verify_time(in_time):    

Re: [Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
Thank you  very much for the help and the math explanation from Omer.  Much of my math background is based on  brute force methodology. Obviously, things have changed. Really changed. Time to do some reading about regex. And here I thought I was slick working with lists and strings. Robert

[Tutor] Python and HSQL

2008-09-04 Thread Derek Croxton
Is there a way to connect to an HSQL database via Python? After some googling, the only way I can find is to use jython and connect via jdbc. I don't want to use jython, so I'm hoping there is another way. -- Sincerely, Derek ___ Tutor maillist - T

Re: [Tutor] Fwd: Need help with Factorial algorithm using Python

2008-09-04 Thread Chris Fuller
The point of a lot of these challenges is to be smart with your math as well as your code. A brute force approach isn't going to work very well, especially in this case. An integer with 7^20 trailing zeros isn't even going to fit in your RAM. An observation: every trailing zero implies a fac

Re: [Tutor] Message 'list' object has no attribute 'strptime ?

2008-09-04 Thread greg whittier
On Thu, Sep 4, 2008 at 2:00 PM, Wayne Watson <[EMAIL PROTECTED]>wrote: > The line > x = time.strptime(fmt_time, "%H %M %S") > with fmt_time = "11 12 40" > in function produces the msg: > Traceback (most recent call last): > File > "C:\Sandia_Meteors\Improved_Sentinel\Sentinel_Playground\Uti

[Tutor] Message 'list' object has no attribute 'strptime ?

2008-09-04 Thread Wayne Watson
Title: Signature.html The line     x = time.strptime(fmt_time, "%H %M %S") with fmt_time = "11 12 40" in function produces the msg: Traceback (most recent call last):   File "C:\Sandia_Meteors\Improved_Sentinel\Sentinel_Playground\Utility_Dev\SU_DateTimeAdjust.py", line 209, in ?     if not ve

[Tutor] Fwd: Need help with Factorial algorithm using Python

2008-09-04 Thread Luke Paireepinart
Oops, accidentally replied off list. -- Forwarded message -- From: Luke Paireepinart <[EMAIL PROTECTED]> Date: Thu, Sep 4, 2008 at 9:39 AM Subject: Re: [Tutor] Need help with Factorial algorithm using Python To: Robert Berman <[EMAIL PROTECTED]> On Thu, Sep 4, 2008 at 8:59 AM,

[Tutor] Need help with Factorial algorithm using Python

2008-09-04 Thread Robert Berman
I am using both the THINK PYTHON text and the Challenge-You website to learn Python. I am doing reasonably well and certainly enjoy the available challenges. I am currently attempting to work a challenge known as the 'Zeros of a Factorial' challenge located at http://www.challenge-you.com/ch

Re: [Tutor] Beginner issue with Tkinter Listbox

2008-09-04 Thread Alan Gauld
"David Johnson" <[EMAIL PROTECTED]> wrote However, as soon as call the method: ListboxName.selection_set(0), the lower frame (containing the Listbox), ends up on the top row, covering the orginal top frame. I am working using a mac and XCode, (cocoa-python project). Just as an additional poi

Re: [Tutor] cmd module

2008-09-04 Thread Martin Walsh
Kent Johnson wrote: > On Thu, Sep 4, 2008 at 1:00 AM, Tony Cappellini <[EMAIL PROTECTED]> wrote: >> I was just reading the PYMOTW article on the cmd module, and trying >> the examples. >> >> http://www.doughellmann.com/PyMOTW/cmd/cmd.html >> >> Scroll down to Auto-Completion. >> >> Does the tab k

Re: [Tutor] cmd module

2008-09-04 Thread Kent Johnson
On Thu, Sep 4, 2008 at 1:00 AM, Tony Cappellini <[EMAIL PROTECTED]> wrote: > I was just reading the PYMOTW article on the cmd module, and trying > the examples. > > http://www.doughellmann.com/PyMOTW/cmd/cmd.html > > Scroll down to Auto-Completion. > > Does the tab key work for anyone running Windo