Re: [Tutor] no loops

2006-07-11 Thread Alan Gauld
> def increment(time, seconds): > time.seconds = time.seconds + seconds > > while time.seconds >= 60: >time.seconds = time.seconds - 60 >time.minutes = time.minutes + 1 Tale a look at what this loop is doing. Think about its purpose. If you werre doing this with paper and pencil would

Re: [Tutor] How do I get my machine to run an SMTP server?

2006-07-11 Thread Luke Paireepinart
[snip code] > *When I run the program using IDLE, I get the following:* > > Send the contents of a directory as a MIME message. > > Usage: dirmail [options] from to [to ...]* > > Options: > -h / --help > Print this message and exit. > > -d directory > --directory=directo

Re: [Tutor] Need Help

2006-07-11 Thread Luke Paireepinart
[snip] > It would be very cruel to not address the core reason why the student's > struggling. That's why we don't "answer" homework questions: it doesn't > address what's often a much bigger problem with the student's concepts of > programming. Thank you for this explanation, Danny. I thought

[Tutor] How do I get my machine to run an SMTP server?

2006-07-11 Thread Grady Henry
This is a program that I wrote using the third example at 12.2.13 Examples at python.org.   #!/usr/bin/env python   """Send the contents of a directory as a MIME message.   Usage: dirmail [options] from to [to ...]*   Options:    -h / --help    Print this message and exit.       -d dir

Re: [Tutor] no loops

2006-07-11 Thread Bob Gailer
Christopher Spears wrote: > I am working on another problem from "How To Think > Like A Computer Scientist". Here is a function: > > def increment(time, seconds): > time.seconds = time.seconds + seconds > > while time.seconds >= 60: > time.seconds = time.seconds - 60 > time.minutes = t

Re: [Tutor] quickie: a better dynamic dictionary update?

2006-07-11 Thread John Fouhy
On 12/07/06, Marcus Goldfish <[EMAIL PROTECTED]> wrote: > # 1st, find the 'stale' items in our dictionary to delete > # lstKeepers is a list of current pictures > # Note: if I try to iterate over the keys of the dict and > # remove-as-I-go, I get an exception (dict size changed > # during iteration

Re: [Tutor] quickie: a better dynamic dictionary update?

2006-07-11 Thread Terry Carroll
On Tue, 11 Jul 2006, Terry Carroll wrote: > On Tue, 11 Jul 2006, Marcus Goldfish wrote: > > > # 1st, find the 'stale' items in our dictionary to delete > > # lstKeepers is a list of current pictures > > # Note: if I try to iterate over the keys of the dict and > > # remove-as-I-go, I get an excep

Re: [Tutor] quickie: a better dynamic dictionary update?

2006-07-11 Thread Terry Carroll
On Tue, 11 Jul 2006, Marcus Goldfish wrote: > # 1st, find the 'stale' items in our dictionary to delete > # lstKeepers is a list of current pictures > # Note: if I try to iterate over the keys of the dict and > # remove-as-I-go, I get an exception (dict size changed > # during iteration) > lstRemo

Re: [Tutor] Need Help

2006-07-11 Thread Marc Poulin
--- Terry Carroll <[EMAIL PROTECTED]> wrote: > On Tue, 11 Jul 2006, Michael P. Reilly wrote: > > > Another aspect of your assignment will be to be > able to use this > > functionality from the "command-line". This > means: without asking questions > > from the user, but input is being passed

Re: [Tutor] no loops

2006-07-11 Thread Marc Poulin
--- John Fouhy <[EMAIL PROTECTED]> wrote: > On 12/07/06, Christopher Spears > <[EMAIL PROTECTED]> wrote: > > Now the exercise is: > > As an exercise, rewrite this function so that it > > doesn't contain any loops. > > > > I have been staring at this function and drawing a > > blank. Something te

[Tutor] quickie: a better dynamic dictionary update?

2006-07-11 Thread Marcus Goldfish
Hi,I need to keep an updated dictionary of pictures in my application.  I have a function which takes snapshots of the current pictures available.  Some of the pictures in my dictionary have been deleted, so their dict entry needs to be removed.  Here is a snippet of very ugly code I have which wor

Re: [Tutor] Need Help

2006-07-11 Thread Terry Carroll
On Tue, 11 Jul 2006, Michael P. Reilly wrote: > Another aspect of your assignment will be to be able to use this > functionality from the "command-line". This means: without asking questions > from the user, but input is being passed as arguments. John should get clarification from his instr

Re: [Tutor] no loops

2006-07-11 Thread John Fouhy
On 12/07/06, Christopher Spears <[EMAIL PROTECTED]> wrote: > Now the exercise is: > As an exercise, rewrite this function so that it > doesn't contain any loops. > > I have been staring at this function and drawing a > blank. Something tells me that I need to use > iteration, but I am not sure how

Re: [Tutor] no loops

2006-07-11 Thread Gregor Lingl
Christopher Spears schrieb: IF you know that it's 2 seconds after midnight, how many hours, minutes, seconds after midnight ist this. If you should compute this by hand, how would you proceed? Best wishes, Gregor > I am working on another problem from "How To Think > Like A Computer Scienti

[Tutor] no loops

2006-07-11 Thread Christopher Spears
I am working on another problem from "How To Think Like A Computer Scientist". Here is a function: def increment(time, seconds): time.seconds = time.seconds + seconds while time.seconds >= 60: time.seconds = time.seconds - 60 time.minutes = time.minutes + 1 while time.minutes >= 6

Re: [Tutor] Need Help

2006-07-11 Thread Kent Johnson
Shappell, John J CW2 wrote: > > Here is the assignment > > 1. You've been given an assignment by your supervisor to > program a small application to monitor the current status > of the cash account in the firm's petty cash fund (the > amount of cash kept

Re: [Tutor] Need Help

2006-07-11 Thread Michael P. Reilly
On 7/10/06, Shappell, John J CW2 <[EMAIL PROTECTED]> wrote: Here is the assignment You've been given an assignment by your supervisor to program a small application to monitor the current status of the cash account in the firm's petty cash fund (the amount of cash kept on hand in the off

Re: [Tutor] modbus communication with python?

2006-07-11 Thread Jeff Peery
okay, yes thank you! I have seen this, although I looked a the code and it appears that this is actually a modbus server (please correct me if I am wrong, I am really new to modbus and PLC's). We are already using a modbus server (KEPDirect for PLC's, automation direct) and I beleive we are using a

Re: [Tutor] How can I copy files recursively?

2006-07-11 Thread Alan Gauld
>> Or you could just use mv on the top level folder. >> > But I don't want the sub folders to come along with the copy. I'd > like to > grab the mp3 files out of a set of subfolders and place them all > into a > single folder somewhere else. Ah, sorry, I misunderstood the question. In that case

Re: [Tutor] Need Help

2006-07-11 Thread Danny Yoo
> By posting the entire homework problem, John Shappell did give the > impression that he wanted us to do the problem for him, but as John > Montgomery notes he is just looking for a hint in an area where he is > stuck. That is fine for the tutor list. Since we know it is homework we > can use

Re: [Tutor] Need Help

2006-07-11 Thread Alan Gauld
> [snip assignment] > Please don't ask about homework in the future. Did your professor > tell you to submit queries to this list? If so, could you ask him > not to? it's against the policies of the tutor mailing list to give > homework help. Thats a bit extreme. We don't mind giving help on

Re: [Tutor] Help IDLE Compile Problem

2006-07-11 Thread Bob Gailer
Bugra Cakir wrote: > Hi, > > I have two Python source files within editing them via IDLE. > I have a problem. The second file is used by the first file. Some parts > i mean from the second file is used. But when i change the contents of > the > second file and while i'm running the first file with

Re: [Tutor] How can I copy files recursively?

2006-07-11 Thread Richard Querin
On 7/11/06, Alan Gauld <[EMAIL PROTECTED]> wrote: Things which are easy in the shell are usually less easy in Python.In your case a simple cp -r will copy the files and an rm -rf willdelete the originals.Or you could just use mv on the top level folder. But I don't want the sub folders to come alon

Re: [Tutor] How can I copy files recursively?

2006-07-11 Thread Alan Gauld
> subfolders. I'd like to write a quick script to move (not copy) all > the mp3 > files in those folders into a single destination folder. I was > thinking I > could do it easily from the linux command line (cp -r copies the > subfolders > out as well) but I can't figure out how to do it. Is the

[Tutor] Help IDLE Compile Problem

2006-07-11 Thread Bugra Cakir
Hi,I have two Python source files within editing them via IDLE.I have a problem. The second file is used by the first file. Some partsi mean from the second file is used. But when i change the contents of the second file and while i'm running the first file with F5, change doesnt reflectto the runt

Re: [Tutor] Need Help

2006-07-11 Thread Kent Johnson
John or Margaret Montgomery wrote: > On Tue, 11 Jul 2006 06:41:23 -0500 > Luke Paireepinart <[EMAIL PROTECTED]> wrote: > > >> Hi. >> Shappell, John J CW2 wrote: >> >>> Here is the assignment >>> >>> >> [snip assignment] >> Please don't ask about homework in the future. Did your prof

Re: [Tutor] tempfile and passing files around

2006-07-11 Thread Kent Johnson
Gabriel Farrell wrote: > On Tue, Jul 11, 2006 at 03:04:02PM -0400, Kent Johnson wrote: > >> Try bob.flush() instead of bob.read(), my guess is the read() is forcing >> a flush(). >> > > That works! Thanks, Kent. If I understand flush (looking at [1]), I > got no output because the data f

Re: [Tutor] tempfile and passing files around

2006-07-11 Thread Gabriel Farrell
On Tue, Jul 11, 2006 at 03:04:02PM -0400, Kent Johnson wrote: > Try bob.flush() instead of bob.read(), my guess is the read() is forcing > a flush(). That works! Thanks, Kent. If I understand flush (looking at [1]), I got no output because the data for the stream wasn't written to the file befo

Re: [Tutor] Need Help

2006-07-11 Thread John or Margaret Montgomery
On Tue, 11 Jul 2006 06:41:23 -0500 Luke Paireepinart <[EMAIL PROTECTED]> wrote: > Hi. > Shappell, John J CW2 wrote: > > > > Here is the assignment > > > [snip assignment] > Please don't ask about homework in the future. Did your professor tell > you to submit queries to this list? If so, could

Re: [Tutor] tempfile and passing files around

2006-07-11 Thread Kent Johnson
Gabriel Farrell wrote: > I have an issue with the tempfile module that I can't figure out. > > Snippet of relevant script looks like so: > > 1 bob = tempfile.NamedTemporaryFile() > 2 bob.write('Hallo!') > 3 bob.read() > 4 sam = tempfile.NamedTemporaryFile() > 5 bobHandle = file(bob.name)

[Tutor] tempfile and passing files around

2006-07-11 Thread Gabriel Farrell
I have an issue with the tempfile module that I can't figure out. Snippet of relevant script looks like so: 1 bob = tempfile.NamedTemporaryFile() 2 bob.write('Hallo!') 3 bob.read() 4 sam = tempfile.NamedTemporaryFile() 5 bobHandle = file(bob.name) 6 bobHandle.read() As you can see, I

Re: [Tutor] How can I copy files recursively?

2006-07-11 Thread Michael P. Reilly
On 7/10/06, Richard Querin <[EMAIL PROTECTED]> wrote: I know this is probably a dumb question:I've got mp3 files that are downloaded (by ipodder) into individual subfolders. I'd like to write a quick script to move (not copy) all the mp3 files in those folders into a single destination folder. I wa

Re: [Tutor] printing 00

2006-07-11 Thread Shantanoo Mahajan
+++ Christopher Spears [10-07-06 21:34 -0700]: | I'm working on a problem from "How To Think Like A | Computer Scientist". I created a Time class: | | class Time: | | def __init__(self, hours, minutes, seconds): | self.hours = hours | self.minutes = minut

Re: [Tutor] Need Help

2006-07-11 Thread Luke Paireepinart
Hi. Shappell, John J CW2 wrote: > > Here is the assignment > [snip assignment] Please don't ask about homework in the future. Did your professor tell you to submit queries to this list? If so, could you ask him not to? it's against the policies of the tutor mailing list to give homework help.

[Tutor] Need Help

2006-07-11 Thread Shappell, John J CW2
Title: [Tutor] Need Help Here is the assignment You've been given an assignment by your supervisor to program a small application to monitor the current status of the cash account in the firm's petty cash fund (the amount of cash kept on hand in the office for incidental purchases). The requ

Re: [Tutor] How can I copy files recursively?

2006-07-11 Thread Kent Johnson
John Fouhy wrote: > On 11/07/06, Richard Querin <[EMAIL PROTECTED]> wrote: > >> I know this is probably a dumb question: >> >> I've got mp3 files that are downloaded (by ipodder) into individual >> subfolders. I'd like to write a quick script to move (not copy) all the mp3 >> files in those fold