Re: [Tutor] os.startfile

2010-12-19 Thread Alan Gauld
"Lang Hurst" wrote I can't install anything at work (XP computer), hence the stand alone file. Then when I run it, everything works fine, except when I get to the point where I want notepad to open the file. I can browse to the file and manually open it with notepad and it's fine. It just

Re: [Tutor] os.startfile

2010-12-19 Thread Lang Hurst
On 12/19/2010 01:16 PM, Steven D'Aprano wrote: Lang Hurst wrote: I have the following in my program: try: os.startfile('current_credit.txt') except: os.system('/usr/bin/xdg-open current_credit.txt') Basically, open a file in notepad if I'm on windows,

Re: [Tutor] Problem with print

2010-12-19 Thread David Hutto
On Sun, Dec 19, 2010 at 4:33 PM, Hugo Arts wrote: > On Sun, Dec 19, 2010 at 10:11 PM, Sander Sweers > wrote: >> On 19 December 2010 21:54, jtl999 wrote: >>>  File "GettingStarted.py", line 91 >>>    print ("Lesson Two") >>>        ^ >>> SyntaxError: invalid syntax >>> >>> Python 2.6.5 >> >> You

Re: [Tutor] Problem with print

2010-12-19 Thread Hugo Arts
On Sun, Dec 19, 2010 at 10:11 PM, Sander Sweers wrote: > On 19 December 2010 21:54, jtl999 wrote: >>  File "GettingStarted.py", line 91 >>    print ("Lesson Two") >>        ^ >> SyntaxError: invalid syntax >> >> Python 2.6.5 > > You are using a howto for python version 3.X but you are using pytho

Re: [Tutor] Problem with print

2010-12-19 Thread Sander Sweers
On 19 December 2010 21:54, jtl999 wrote: >  File "GettingStarted.py", line 91 >    print ("Lesson Two") >        ^ > SyntaxError: invalid syntax > > Python 2.6.5 You are using a howto for python version 3.X but you are using python 2.X. In python 3 the print statement was changed to a function.

Re: [Tutor] Problem with print

2010-12-19 Thread David Hutto
On Sun, Dec 19, 2010 at 4:05 PM, Alex Hall wrote: > Sorry to top-post (gMail mobile). > This looks like you missed a quote, colon, or something on a line > elsewhere in the file (likely above it). Find that and this should be > fixed. > > On 12/19/10, jtl999 wrote: >>  File "GettingStarted.py", l

Re: [Tutor] os.startfile

2010-12-19 Thread Steven D'Aprano
Lang Hurst wrote: I have the following in my program: try: os.startfile('current_credit.txt') except: os.system('/usr/bin/xdg-open current_credit.txt') Basically, open a file in notepad if I'm on windows, vim if on my home linux computer. It works fin

Re: [Tutor] Problem with print

2010-12-19 Thread Alex Hall
Sorry to top-post (gMail mobile). This looks like you missed a quote, colon, or something on a line elsewhere in the file (likely above it). Find that and this should be fixed. On 12/19/10, jtl999 wrote: > File "GettingStarted.py", line 91 > print ("Lesson Two") > ^ > SyntaxError: in

[Tutor] Problem with print

2010-12-19 Thread jtl999
File "GettingStarted.py", line 91 print ("Lesson Two") ^ SyntaxError: invalid syntax Python 2.6.5 signature.asc Description: This is a digitally signed message part ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscript

[Tutor] os.startfile

2010-12-19 Thread Lang Hurst
I have the following in my program: try: os.startfile('current_credit.txt') except: os.system('/usr/bin/xdg-open current_credit.txt') Basically, open a file in notepad if I'm on windows, vim if on my home linux computer. It works fine in linux and in W

Re: [Tutor] The Template Pattern

2010-12-19 Thread Karim
Thanks a lot to point this out! Karim On 12/19/2010 04:33 AM, Steven D'Aprano wrote: Karim wrote: class InputStrategy( object ): """This InputStrategy class is an abstract interface to various read strategy objects. """ def read(self, filePath): """Abstract method to

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread lei yang
On Sun, Dec 19, 2010 at 9:05 PM, Sander Sweers wrote: > On 19 December 2010 13:43, lei yang wrote: >> Right, it gets stuck at the readline(), is there a function not get >> stuck to instead of readline(). > > readline() will keep reading stdout until it received a newline > character. So if there

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread Sander Sweers
On 19 December 2010 13:43, lei yang wrote: > Right, it gets stuck at the readline(), is there a function not get > stuck to instead of readline(). readline() will keep reading stdout until it received a newline character. So if there is nothing to read it will wait forever. The solution is to wai

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread lei yang
On Sun, Dec 19, 2010 at 8:29 PM, Evert Rol wrote: >> #!/usr/bin/env python >> import datetime >> import subprocess >> import sys >> import os >> import signal >> from time import sleep >> >> def host_run(cmd, secs=10): >>    print("running %s" % cmd) >>

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread Evert Rol
> #!/usr/bin/env python > import datetime > import subprocess > import sys > import os > import signal > from time import sleep > > def host_run(cmd, secs=10): >print("running %s" % cmd) >timeout = datetime.timedelta(seconds=secs) >proc =

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread lei yang
On Sun, Dec 19, 2010 at 8:09 PM, Evert Rol wrote: #!/usr/bin/env python import datetime import subprocess import sys import os import signal from time import sleep def host_run(cmd, secs=10):    print("running %s" % cmd)    timeout = datetime.

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread Evert Rol
>>> #!/usr/bin/env python >>> import datetime >>> import subprocess >>> import sys >>> import os >>> import signal >>> from time import sleep >>> >>> def host_run(cmd, secs=10): >>>print("running %s" % cmd) >>>timeout = datetime.timedelta(seconds=secs) >>>proc = subprocess.Popen(cmd, s

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread lei yang
On Sun, Dec 19, 2010 at 7:56 PM, Evert Rol wrote: >> #!/usr/bin/env python >> import datetime >> import subprocess >> import sys >> import os >> import signal >> from time import sleep >> >> def host_run(cmd, secs=10): >>    print("running %s" % cmd) >>    timeout = datetime.timedelta(seconds=secs

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread Evert Rol
> #!/usr/bin/env python > import datetime > import subprocess > import sys > import os > import signal > from time import sleep > > def host_run(cmd, secs=10): >print("running %s" % cmd) >timeout = datetime.timedelta(seconds=secs) >proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, >

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread lei yang
#!/usr/bin/env python import datetime import subprocess import sys import os import signal from time import sleep def host_run(cmd, secs=10): print("running %s" % cmd) timeout = datetime.timedelta(seconds=secs) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDO

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread lei yang
On Sun, Dec 19, 2010 at 4:57 PM, Alan Gauld wrote: > > "lei yang" wrote > > > def runForAWhile(cmd, secs=10): >   print("running %s" % cmd) >   timeout = datetime.timedelta(seconds=secs) >   print timeout >   proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, > stderr=subprocess.STDOUT, shell=T

Re: [Tutor] why "ifconfig" is alway running?

2010-12-19 Thread Alan Gauld
"lei yang" wrote def runForAWhile(cmd, secs=10): print("running %s" % cmd) timeout = datetime.timedelta(seconds=secs) print timeout proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True) status = proc.poll() You are still only checking status