RE: [PyCrust] 0.6 in the oven, now with PyFilling, should be done cooking soon
Brought to you by:
pobrien
From: Patrick K. O'B. <po...@or...> - 2001-09-09 01:15:45
|
The code for runfile should give you one idea for how to get around this. I'm open to suggestions for improving this mechanism. def run(self, command, prompt=1, verbose=1): """Execute command within the shell as if it was typed in directly. >>> shell.run('print "this"') >>> print "this" this >>> """ command = command.rstrip() if prompt: self.prompt() if verbose: self.write(command) self.push(command) def runfile(self, filename): """Execute all commands in file as if they were typed into the shell.""" file = open(filename) try: self.prompt() for command in file.readlines(): if command[:6] == 'shell.': # Run shell methods silently. self.run(command, prompt=0, verbose=0) else: self.run(command, prompt=0, verbose=1) finally: file.close() --- Patrick K. O'Brien Orbtech (http://www.orbtech.com) "I am, therefore I think." -----Original Message----- From: pyc...@li... [mailto:pyc...@li...]On Behalf Of Raul Cota Sent: Saturday, September 08, 2001 6:33 PM To: pyc...@li... Subject: Re: [PyCrust] 0.6 in the oven, now with PyFilling, should be done cooking soon <snip> 2) My application uses a lot the run command in shell.py, and there's something I don't particullary like. The code: sh.run('r = 5') sh.run('x = 6') sh.run('t = 8') gives the following output in the interpreter >>> >>> r = 5 >>> >>> x = 6 >>> >>> t = 8 >>> instead of >>> r = 5 >>> x = 6 >>> t = 8 the method run, writes the ouptut one line after the active line, so, if the active line is somewhere above... things like this happen (I ran the same code several times)... >>> parentFlowsh.Solve() myFlash >>> parentFlowsh.Solve() myFlash1 >>> 1 >>> >>> parentFlowsh.Solve() myFlash1 >>> >>> parentFlowsh.Solve() myFlash1 >>> >>> par >>> parentFlowsh.Solve() myFlash1 >>> entFlowsh.Solve() myFlash1 >>> parentFlowsh.Solve() myFlash1 >>> Every two lines it should say .... >>> parentFlowsh.Solve() myFlash1 Right now, I was working on trying to fix Raul |