[Tutor] python's bash wait and ampersand equivalent?

2005-04-25 Thread chumpy town
Hello all, I am trying to convert from bash to python for scripting. What is the simplest & cleanest way to do the following in python: #!/bin/bash for i in `seq 1 1000` do my-other-script & done wait echo "all done" I at first tried os.system("my-other-script &") and os.wait() but this caus

[Tutor] properties and subclasses

2005-04-25 Thread Brian van den Broek
Hi all, I'm trying to get a hang of properties. It isn't quite clear to me what is the best way to make properties differ in subclasses. Some code snips to show what I've tried: class A(object): ... def __init__(self): pass ... def prop_set(self): return "I was set by A's method" ... my

Re: [Tutor] using TK to view an image and then close the window

2005-04-25 Thread jfouhy
Quoting "Ertl, John" <[EMAIL PROTECTED]>: > top = Tkinter.Toplevel(app,visual="truecolor",colormap="new") > top.title(mainTitle) > top.protocol("WM_DELETE_WINDOW", quit) > top.bind("",quit) > top.bind("",quit) In addition to Michael's comments, to bind to a keypress, you just do (eg) widget.

Re: [Tutor] variable scope in nested functions

2005-04-25 Thread Kent Johnson
Logesh Pillay wrote: Thanks Kent for your reply. You said This is a limitation of Python's nested scopes. You can't assign to a variable in an enclosing scope. One way to work around this is to use a mutable value like a list in the enclosing scope: def foo (n): counter = [0] def choose (i)

Re: [Tutor] using TK to view an image and then close the window

2005-04-25 Thread Michael Lange
On Mon, 25 Apr 2005 10:24:08 -0700 "Ertl, John" <[EMAIL PROTECTED]> wrote: Hi John, > I can get the image to show > up and minimize and maximize but I can not get the window to close and then > display the next image. > > I have tired several things but no luck. > > Any help on getting the

[Tutor] Re: variable scope in nested functions: SOLUTION :-)

2005-04-25 Thread André Roberge
Logesh Pillay wrote: [snip] Consider a program I've just translated into python from my version in C. def erdos(n): global found # added line found, r, s = False, 1, [0]*1000 def choose (d, k): global found # ad

[Tutor] Re: Highlighting instructions: pedagogical preferences

2005-04-25 Thread André Roberge
Alan Gauld wrote: (and Kent Johnson agrees :-) [snip] Its conventional to take the second option - it allows the student to examine the highlighted line before it operates. The alternative could be confusing if, for example you jump into a function. [snip] think it's a good idea. Have you seen th

Re: [Tutor] Re: design questions: pythonic appraoch to ostriches

2005-04-25 Thread Alan Gauld
> (I took a brief detour into Common Lisp after joining > this list, not too long ago. Thanks Mr. Gauld.) YOu are welcome, everyone should at least dabble in Lisp if only because it teaches you so much about the fundamentals of programming. > method in a subclass. From my limited dealings with

Re: [Tutor] Highlighting instructions: pedagogical preferences

2005-04-25 Thread Alan Gauld
> Question: should the highlighted instruction be the one that has just > been executed, or the one that is about to be executed (when the user > clicks on the step button, for example)? Its conventional to take the second option - it allows the student to examine the highlighted line before it op

[Tutor] variable scope in nested functions

2005-04-25 Thread Logesh Pillay
Thanks Kent for your reply. You said This is a limitation of Python's nested scopes. You can't assign to a variable in an enclosing scope. One way to work around this is to use a mutable value like a list in the enclosing scope: def foo (n): counter = [0] def choose (i): if (solution f

RE: [Tutor] Re: design questions: pythonic appraoch to ostriches

2005-04-25 Thread Smith, Jeff
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg T >>Think about it in the abstract. The Bird class makes >>the statement: >>all >>birds fly. Then you want to turn around and define a >>Bird that >>doesn't. >>Even doing >> >>def fly: >> pass >> >>makes no sense since what

[Tutor] Re: design questions: pythonic appraoch to ostriches

2005-04-25 Thread Greg T
Greetings. Any comments made by me will certainly not be the 'pythonic' way to do things, but I would like to make a few comments on the subject, and possibly weave in a few questions of my own. (I took a brief detour into Common Lisp after joining this list, not too long ago. Thanks Mr. Gauld.) >

Re: [Tutor] Re Help with this script

2005-04-25 Thread Alan Gauld
> can't see it really, i thought that the fact to have the "break" command > would terminate the script straight away. break terminates the current loop, which is inside your print_options function. print_options is called from inside print_options. Research the term "recursion" and see if you ca

Re: [Tutor] Highlighting instructions: pedagogical preferences

2005-04-25 Thread Kent Johnson
André Roberge wrote: I'm writing a program "interpreter" which has two windows: a program editing window and a program output window. The interpreter can either step through the program automatically, at a slow pace, or step through the program one instruction at a time, as the user "clicks" on

[Tutor] RE: using TK to view an image and then close the window

2005-04-25 Thread Ertl, John
I forgot to mention that I am running on a Linux system if that makes any difference for the TK part. Thanks, John Ertl -Original Message- From: Ertl, John Sent: Monday, April 25, 2005 10:24 To: tutor@python.org Subject: using TK to view an image and then close the window All, I hav

[Tutor] using TK to view an image and then close the window

2005-04-25 Thread Ertl, John
All, I have been struggling with being able to view an image and most things have not worked for one reason or another so I am trying to fall back on a way I used to do it in PERL. Use TK to show the image. I do not know TKInter but I have two scripts one that gets a list of images and anouther

Re: [Tutor] Highlighting instructions: pedagogical preferences

2005-04-25 Thread Max Noel
On Apr 25, 2005, at 17:03, André Roberge wrote: I'm writing a program "interpreter" which has two windows: a program editing window and a program output window. The interpreter can either step through the program automatically, at a slow pace, or step through the program one instruction at a tim

[Tutor] Highlighting instructions: pedagogical preferences

2005-04-25 Thread André Roberge
I'm writing a program "interpreter" which has two windows: a program editing window and a program output window. The interpreter can either step through the program automatically, at a slow pace, or step through the program one instruction at a time, as the user "clicks" on a "step button". Th

Re: [Tutor] Re Help with this script

2005-04-25 Thread John Carmona
Thanks Kent, as far as I can see I get the same problem that on my script, i need to enter "f" 3 to 4 times before I exit the programme. Hmmm, why, I can't see it really, i thought that the fact to have the "break" command would terminate the script straight away. If I enter "f" first then the

RE: [Tutor] design questions: pythonic approach to ostriches

2005-04-25 Thread Smith, Jeff
This is an excellent observation and points to the real problem with the original question. The problem is that the base class has more features than some of the classes that will be dervied from it which is usually just plain wrong. Think about it in the abstract. The Bird class makes the state

Re: [Tutor] CLS?

2005-04-25 Thread Chris Smith
I have this in my misc library. It was my last attempt at unifying the cls function snippets that I got when I asked about this question some time ago (check the ASPN tutor archives for 'cls'). After adding "darwin" to the test for the system (instead of just 'mac') I got it to work from a sc

[Tutor] Re: Weird import problem with PythonIDE on Mac (was 'import problem')

2005-04-25 Thread Chris Smith
On Friday, Apr 22, 2005, at 10:00 America/Chicago, Max Noel wrote: Do you have a suggestion as to what can I give a module so it has enough information to execute a function that resides in __main__? Here is a visual of what is going on: --__main__ def y1(): pass import foo foo.run(string