Re: [Tutor] file/subprocess error

2009-06-11 Thread Alan Gauld
"Essah Mitges" wrote But will it work I run 3 module for this game utilites is just 1 It doesn't matter how many modules you use, although it changes how many you have to import maybe. But in princiople if your game is started by calling a single function then you only need to import th

Re: [Tutor] delphi, pascal and Python

2009-06-11 Thread andy
Hi People The error in this code was that the free pascal compiler command listed below included a framework command suitable only for mac compilations fpc -MDelphi -Cirot -O1 -gl -XX -k-framework -kpython -WG -vewnhi -l -Fu. -oPyMinMod.so PyMinMod.dpr The removal of this framework command caus

[Tutor] file enigma

2009-06-11 Thread spir
Hello, text = file(filename).read() (or: open(filename).read()) How do you close() the file? ;-) Is it, in fact, automagically closed after end-of-statement if not bound to a name? Or when the execution path quits the present scope (func, module), like if it had been bound to a local var? Or w

Re: [Tutor] file enigma

2009-06-11 Thread Tim Golden
spir wrote: Hello, text = file(filename).read() (or: open(filename).read()) How do you close() the file? ;-) Well, in any version of Python, you can do this: f = open (filename) text = f.read () f.close () or, slightly more robsustly: f = open (filename) try: text = f.read () finally:

Re: [Tutor] Parse Text File

2009-06-11 Thread spir
[Hope you don't mind I copy to the list. Not only it can help others, but pyparsing users read tutor, including Paul MacGuire (author).] Le Thu, 11 Jun 2009 11:53:31 +0200, Stefan Lesicnik s'exprima ainsi: [...] I cannot really answer precisely for haven't used pyparsing for a while (*). So,

[Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Alun Griffiths
Hi I have a legacy (FORTRAN) program called POLY.EXE which asks the user interactively for three inputs (file names) from the keyboard. I would like to run this program in batch and tried to replace the interactive prompts with file names stored in a separate file using this Python script:

[Tutor] How do I do this in python?

2009-06-11 Thread Robert Lummis
I want to write a function that I can use for debugging purposes that prints the values of whatever list of object references it is given as arguments, without knowing in advance how many object references it will be called with or what they might be. For example, the call: show(a,b,c) would output

Re: [Tutor] Syntax Error First Example

2009-06-11 Thread Kent Johnson
On Wed, Jun 10, 2009 at 10:02 PM, Randy Trahan wrote: > First, I am suppose to put this in the script mode vs the IDLE mode correct? > He failed to mention where.. Generally the "Python Shell" window is for interactive exploration and to see the results of your scripts. To type in a complete prog

Re: [Tutor] file enigma

2009-06-11 Thread spir
Le Thu, 11 Jun 2009 10:21:31 +0100, Tim Golden s'exprima ainsi: > spir wrote: > > Hello, > > > > text = file(filename).read() > > > > (or: open(filename).read()) > > > > How do you close() the file? ;-) > > Well, in any version of Python, you can do this: > > > f = open (filename) > text =

Re: [Tutor] How do I do this in python?

2009-06-11 Thread The Green Tea Leaf
My advice: "Learning Python" very nice book def show(*args): print args def show2(*args): for item in args: print "Blabla:",item show(1,2,"hello") show2(1,2,"hello") On Thu, Jun 11, 2009 at 03:43, Robert Lummis wrote: > I want to write a function that I can use f

Re: [Tutor] file enigma

2009-06-11 Thread Tim Golden
spir wrote: Thank you, Tim, this really answers my question. Glad to be of help :) * I intended to write a helper func "filetext(filename)" to open/read/close/return (or equivalent using the with idiom). This is one of those tricky things in Python: when the "raw" code is possibly one lin

Re: [Tutor] How do I do this in python?

2009-06-11 Thread Kent Johnson
On Wed, Jun 10, 2009 at 9:43 PM, Robert Lummis wrote: > I want to write a function that I can use for debugging purposes that > prints the values of whatever list of object references it is given as > arguments, without knowing in advance how many object references it > will be called with or what

Re: [Tutor] How do I do this in python?

2009-06-11 Thread A.T.Hofkamp
Robert Lummis wrote: I want to write a function that I can use for debugging purposes that prints the values of whatever list of object references it is given as arguments, without knowing in advance how many object references it will be called with or what they might be. For example, the call: s

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Wayne
On Thu, Jun 11, 2009 at 3:08 AM, Alun Griffiths < alun.griffi...@dsl.pipex.com> wrote: > Hi > > I have a legacy (FORTRAN) program called POLY.EXE which asks the user > interactively for three inputs (file names) from the keyboard. I would like > to run this program in batch and tried to replace t

Re: [Tutor] How do I do this in python?

2009-06-11 Thread spir
Le Thu, 11 Jun 2009 12:56:27 +0200, The Green Tea Leaf s'exprima ainsi: > My advice: "Learning Python" very nice book > > def show(*args): > print args > > def show2(*args): > for item in args: > print "Blabla:",item > > show(1,2,"hello") > show2(1,2,"hello") Well, i

Re: [Tutor] How do I do this in python?

2009-06-11 Thread spir
Le Thu, 11 Jun 2009 13:12:02 +0200, "A.T.Hofkamp" s'exprima ainsi: > > If this can't be done but there is a completely different way to > > achieve a similar result, what is it? > > print "abc=", a, b, c > > is what I always use. Well, I do find the OP's demand really sensible. Had the same ne

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread eShopping
Hi I have a legacy (FORTRAN) program called POLY.EXE which asks the user interactively for three inputs (file names) from the keyboard. I would like to run this program in batch and tried to replace the interactive prompts with file names stored in a separate file using this Python script:

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread A.T.Hofkamp
eShopping wrote: import subprocess x = subprocess.Popen(args="poly.exe",stdin=subprocess.PIPE) for item in ["polyin.dat", "polyout.dat", "polyout.plt"]: x.stdin.write('%s\n' % item) but got the same error message Above code would seem to be correct. Are you sure the Fortran program ac

Re: [Tutor] How do I do this in python?

2009-06-11 Thread Lie Ryan
Robert Lummis wrote: > I want to write a function that I can use for debugging purposes that > prints the values of whatever list of object references it is given as > arguments, without knowing in advance how many object references it > will be called with or what they might be. For example, the c

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread eShopping
At 13:26 11/06/2009, you wrote: eShopping wrote: import subprocess x = subprocess.Popen(args="poly.exe",stdin=subprocess.PIPE) for item in ["polyin.dat", "polyout.dat", "polyout.plt"]: x.stdin.write('%s\n' % item) but got the same error message Above code would seem to be correct. Are you

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Lie Ryan
eShopping wrote: > At 13:26 11/06/2009, you wrote: >> eShopping wrote: >>> import subprocess >>> x = subprocess.Popen(args="poly.exe",stdin=subprocess.PIPE) >>> for item in ["polyin.dat", "polyout.dat", "polyout.plt"]: >>> x.stdin.write('%s\n' % item) >>> but got the same error message >> >> Ab

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Alan Gauld
"eShopping" wrote C:\> poly.exe < poly_files.txt in a CMD program (or COMMAND or whatever the console program is called nowadays at Win* systems). Tried piping the input as suggested but POLY ignores the pipe and just asks me for the names of the files as if we were in interactive mode.

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread A.T.Hofkamp
eShopping wrote: At 13:26 11/06/2009, you wrote: Are you sure the Fortran program accepts the names? One easy way to test this is to try C:\> poly.exe < poly_files.txt in a CMD program (or COMMAND or whatever the console program is called nowadays at Win* systems). Tried piping the input as

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread eShopping
>> eShopping wrote: >>> import subprocess >>> x = subprocess.Popen(args="poly.exe",stdin=subprocess.PIPE) >>> for item in ["polyin.dat", "polyout.dat", "polyout.plt"]: >>> x.stdin.write('%s\n' % item) >>> but got the same error message >> >> Above code would seem to be correct. >> >> Are you

Re: [Tutor] How do I do this in python?

2009-06-11 Thread Kent Johnson
On Wed, Jun 10, 2009 at 9:43 PM, Robert Lummis wrote: > I want to write a function that I can use for debugging purposes that > prints the values of whatever list of object references it is given as > arguments, without knowing in advance how many object references it > will be called with or what

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Tino Dai
Hi, I know that this is a python group but you might want to try the open source utility called Expect. It does what you need it to do without having having to go through this trial and error process with subprocess. http://expect.nist.gov/ -Tino On Thu, Jun 11, 2009 at 9:45 AM, eShopping w

Re: [Tutor] How do I do this in python?

2009-06-11 Thread Emile van Sebille
On 6/11/2009 4:08 AM Kent Johnson said... On Wed, Jun 10, 2009 at 9:43 PM, Robert Lummis wrote: I want to write a function that I can use for debugging purposes that prints the values of whatever list of object references it is given as arguments, without knowing in advance how many object refer

[Tutor] Simple factorial program

2009-06-11 Thread Eddie
I'm trying to write a simple factorial program and am unsure at what is wrong with it. Why Can't I go *factorial = factorial * number* where factorial and number are both integers? #Factorial program print "Factorial finder" number = input("Please enter a non-negative integer: " for number in

Re: [Tutor] Simple factorial program

2009-06-11 Thread vince spicer
did you declare factorial before trying to use it? factorial = 1 print "Factorial finder" number = int(input("Please enter a non-negative integer: ")) for number in range(number, 1) factorial = (factorial * number) print "Factorial:", factorial On Thu, Jun 11, 2009 at 9:53 AM, Eddie wrote:

Re: [Tutor] How do I do this in python?

2009-06-11 Thread spir
Le Thu, 11 Jun 2009 10:46:26 -0400, Kent Johnson s'exprima ainsi: > On Wed, Jun 10, 2009 at 9:43 PM, Robert Lummis > wrote: > > I want to write a function that I can use for debugging purposes that > > prints the values of whatever list of object references it is given as > > arguments, without k

Re: [Tutor] Simple factorial program

2009-06-11 Thread Eddie
Thanks, that is my problem. With that code, why is it giving an error (indenting?) at the end of* for number in range(number, 1) *? 2009/6/12 vince spicer > did you declare factorial before trying to use it? > > factorial = 1 > print "Factorial finder" > number = int(input("Please enter a non-

Re: [Tutor] Simple factorial program

2009-06-11 Thread vince spicer
no ":" after for statement Vince On Thu, Jun 11, 2009 at 10:06 AM, Eddie wrote: > Thanks, that is my problem. > > With that code, why is it giving an error (indenting?) at the end of* for > number in range(number, 1) *? > > 2009/6/12 vince spicer > > did you declare factorial before trying to

Re: [Tutor] Simple factorial program

2009-06-11 Thread ayyaz
Eddie wrote: I'm trying to write a simple factorial program and am unsure at what is wrong with it. Why Can't I go *factorial = factorial * number* where factorial and number are both integers? #Factorial program print "Factorial finder" number = input("Please enter a non-negative integer: "

Re: [Tutor] Simple factorial program

2009-06-11 Thread Eddie
Thanks guys, I got it working for what I need at the moment with #Factorial finder factorialNum = 1L print "Factorial finder" number = int(input("Please enter a non-negative integer: ")) for number in range(1, number): factorialNum = (factorialNum * (number + 1)) print factorialNum print "F

Re: [Tutor] Simple factorial program

2009-06-11 Thread wesley chun
hi eddie, a few more nits to tweak... > factorialNum = 1L change to "1" instead of "1L" -- "L" numbers are going away and will be permanently not available starting in 3.0. > print "Factorial finder" > number = int(input("Please enter a non-negative integer: ")) change "input" to "raw_input".

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Alan Gauld
"Tino Dai" wrote I know that this is a python group but you might want to try the open source utility called Expect. It does what you need it to do without having having to go through this trial and error process with subprocess. http://expect.nist.gov/ Or use the Python wrapper around

Re: [Tutor] Replacing keyboard input to EXE file

2009-06-11 Thread Tino Dai
On Thu, Jun 11, 2009 at 1:15 PM, Alan Gauld wrote: > > "Tino Dai" wrote > >> >> I know that this is a python group but you might want to try the open >> source utility called Expect. It does what you need it to do without >> having >> having to go through this trial and error process with subpr

Re: [Tutor] Simple factorial program

2009-06-11 Thread Dave Angel
Eddie wrote: I'm trying to write a simple factorial program and am unsure at what is wrong with it. Why Can't I go *factorial = factorial * number* where factorial and number are both integers? #Factorial program print "Factorial finder" number = input("Please enter a non-negative integer: "

[Tutor] Help with file editing

2009-06-11 Thread tanner barnes
Ok, so i am creating a program for my school's football team and in one part i need to store a list of variables (their name, height, weight, and grade) in a txt file to bring up later. i know how to create and read from files ( file = open("file_name", ''w/r/a") ). But what i need to do is cre

Re: [Tutor] Simple factorial program

2009-06-11 Thread Emile van Sebille
On 6/11/2009 8:53 AM Eddie said... I'm trying to write a simple factorial program and am unsure at what is wrong with it. Why Can't I go *factorial = factorial * number* where factorial and number are both integers? #Factorial program print "Factorial finder" number = input("Please enter a no

Re: [Tutor] Help with file editing

2009-06-11 Thread Lie Ryan
tanner barnes wrote: > Ok, so i am creating a program for my school's football team and in one > part i need to store a list of variables (their name, height, weight, > and grade) in a txt file to bring up later. i know how to create and > read from files ( file = open("file_name", ''w/r/a") ). But

Re: [Tutor] Parse Text File

2009-06-11 Thread Stefan Lesicnik
> > Hi Denis, > > > > Thanks for your input. So i decided i should use a pyparser and try it > (im a > > relative python noob though!) > Hi Everyone! I have made some progress, although i believe it mainly due to luck and not a lot of understanding (vague understanding maybe). Hopefully this can

[Tutor] Need a solution.

2009-06-11 Thread Raj Medhekar
I have been having some difficulty modifying this program to where a player has limited number of guesses and if he fails to guess correctly within that number he is asked to "Try Again" The original program code and the code that I modified are given below. Thanks for your help. Sincerely, Raj

Re: [Tutor] Need a Solution!

2009-06-11 Thread Raj Medhekar
This email contains another modified code that I tried working with but still doesn't do the job right, although performs closer to what i want. I have been having some difficulty modifying this program to where a player has limited number of guesses and if he fails to guess correctly within that

Re: [Tutor] Need a Solution!

2009-06-11 Thread Wayne
On Thu, Jun 11, 2009 at 1:59 PM, Raj Medhekar wrote: > This email contains another modified code that I tried working with but > still doesn't do the job right, although performs closer to what i want. I > have been having some difficulty modifying this program to where a player > has limited numb

Re: [Tutor] Need a Solution!

2009-06-11 Thread ayyaz
Raj Medhekar wrote: This email contains another modified code that I tried working with but still doesn't do the job right, although performs closer to what i want. I have been having some difficulty modifying this program to where a player has limited number of guesses and if he fails to guess

Re: [Tutor] How do I do this in python?

2009-06-11 Thread Robert Lummis
On Thu, Jun 11, 2009 at 11:58 AM, spir wrote: > Le Thu, 11 Jun 2009 10:46:26 -0400, > Kent Johnson s'exprima ainsi: > >> On Wed, Jun 10, 2009 at 9:43 PM, Robert Lummis >> wrote: >> > I want to write a function that I can use for debugging purposes that >> > prints the values of whatever list of ob

Re: [Tutor] Need a Solution!

2009-06-11 Thread Alan Gauld
"Raj Medhekar" wrote #guessing loop while guess != the_number and tries <5: Well done you correctly spotted that you could use a boolean expression. if guess > the_number: print "Lower..." else: print "Higher..." guess = int(raw_input("Take a guess:")) tries +=

Re: [Tutor] XML: changing value of elements

2009-06-11 Thread Johan Geldenhuys
Thanks for the reply. Have been waiting a few days. When I started out, I still had Python 2.4 and etree is not available in that version. This part : must have snicked in wihen I copied the XML code. Sorry, but that is the location of my original XML file. I'll try your stuff and see how it go

[Tutor] 3.0 on Mac

2009-06-11 Thread acfleck
I'm a Python nubie and having trouble with 3.0.1 on Mac (10.4.11). I did a default install of MacPython 3.0.1. The IDLE.app works fine, but from a Terminal window, the 'python' command still gets me V2.5.3 (the original Apple installed version). A 'python3' command is not recognized. I'd like t

Re: [Tutor] 3.0 on Mac

2009-06-11 Thread wesley chun
> A 'python3' command is not recognized. I'd like to > know what I need to change to access V3.0.1 from a Terminal window. try python3.0 if that doesn't work, then you may have to add the directory where it's installed to your PATH. hope this helps, and welcome to Python! -- wesley - - - - - - -

Re: [Tutor] Help..Concatenaton Error

2009-06-11 Thread ayyaz
Randy Trahan wrote: Attached is an error I cannot get to work, I was doing a print concatenation but it won't let me get past "+ "ibly impressive. " \ (then to next line) Also Programming Lanquage Question: I have studied and an fairly proficient at XHTML and CSS, I tried Javascript but just

Re: [Tutor] 3.0 on Mac

2009-06-11 Thread John Fouhy
2009/6/12 acfleck : > I'm a Python nubie and having trouble with 3.0.1 on Mac (10.4.11). I did a > default install of MacPython 3.0.1. The IDLE.app works fine, but from a > Terminal window, the 'python' command still gets me V2.5.3 (the original > Apple installed version). A 'python3' command is no

[Tutor] PyQt Signal

2009-06-11 Thread Daniel Sarmiento
Hello I am starting to use PyQt, and I'm trying to send a signal across threads, but I get the following error: Traceback (most recent call last): File "/home/daniel/NetBeansProjects/aeropuerto/main.py", line 34, in form = AeropuertoDlg() File "/home/daniel/NetBeansProjects/aeropuerto/ma

Re: [Tutor] Help..Concatenaton Error

2009-06-11 Thread Martin Walsh
ayyaz wrote: > Randy Trahan wrote: >> Attached is an error I cannot get to work, I was doing a print >> concatenation but it won't let me get past "+ "ibly impressive. " \ >> (then to next line) >> >> Also Programming Lanquage Question: >> I have studied and an fairly proficient at XHTML and CSS,

Re: [Tutor] Help..Concatenaton Error

2009-06-11 Thread Dave Angel
Randy Trahan wrote: Attached is an error I cannot get to work, I was doing a print concatenation but it won't let me get past "+ "ibly impressive. " \ (then to next line) If you had included the sample lines in your message, instead of an attachment, then it'd be part of the mailing list, a

Re: [Tutor] 3.0 on Mac

2009-06-11 Thread Dave Angel
acfleck wrote: I'm a Python nubie and having trouble with 3.0.1 on Mac (10.4.11). I did a default install of MacPython 3.0.1. The IDLE.app works fine, but from a Terminal window, the 'python' command still gets me V2.5.3 (the original Apple installed version). A 'python3' command is not reco

Re: [Tutor] Need a solution.

2009-06-11 Thread David
Raj Medhekar wrote: I have been having some difficulty modifying this program to where a player has limited number of guesses and if he fails to guess correctly within that number he is asked to "Try Again" The original program code and the code that I modified are given below. Thanks for your

Re: [Tutor] Need a solution.

2009-06-11 Thread David
Randy Trahan wrote: Well that didin't work I tried the program and it went into an infinite loop...is that the problem you were asking about? On Fri, Jun 12, 2009 at 12:14 AM, Randy Trahan > wrote: Hi Raj, The only thing I see is that under #guessi

Re: [Tutor] Help..Concatenaton Error

2009-06-11 Thread Andre Engels
On Fri, Jun 12, 2009 at 3:00 AM, Randy Trahan wrote: > Attached is an error I cannot get to work, I was doing a print concatenation > but it won't let me get past "+ "ibly impressive. " \ > (then to next line) It's wrong at a few places, but the first is at the very beginning. You need a quote mar