[Tutor] serial -->file tranfer
Hello, I have a modem connect to my Windows XP PC through a serial cable. I Want to transfer the file(e.g '.TXT' format) from XP PC to serial modem and also from Serial modem to winXP PC. Can anybody help me out how to do it in Python and provide some sample code or useful links so that I can proceed further in my project?? All help will be highly appreciated. Thanks & Regards, Govind ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
On Friday 29 February 2008 12:24, Dick Moores wrote: > http://www.kuow.org/real.ram . Try this to start, then turn into a service with FireDaemon, http://www.firedaemon.com/. You'll need to fill in the quit() function, and the particulars for your media player. from time import mktime, strftime, strptime, localtime, time, sleep # return true if the program should exit def quit(): pass import subprocess def launch(): args = ( 'c:\\pathto\\cmd', 'http://www.kuow.org/real.ram' ) subprocess.call(args) # get the seconds since epoch of midnight, add the desired time of day, # and convert back into seconds since epoch. We'll wake up just a bit # early, so we can use a coarser timer. event_time = mktime(strptime(strftime('%Y%m%d', localtime(time()))+'19:59:40','%Y%m%d%H:%M:%S')) while True: while time()http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
I left out the daily increment. there should be a event_time += 86400 end of the inner loop. while True: while time()http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
On Friday 29 February 2008 18:25, Tiger12506 wrote: > time.sleep is not exactly accurate, so I would suggest that you use this > method, short 5 minutes or so and then do a sleep(10) or so in a loop to > get closer to the time. Another advantage to shorter sleeps is it reduces the latency of anything else your program needs to do, such as exit gracefully, reschedule the event, or whatever. Not too short, because that uses more CPU time. It also makes a difference if the clock gets reset :) Cheers ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
time.sleep is not exactly accurate, so I would suggest that you use this method, short 5 minutes or so and then do a sleep(10) or so in a loop to get closer to the time. >>import time >>b = '20:00:00' >> >>(bhour, bmin, bsec) = b.split(':') >>bsec = int(bsec) + int(bmin)*60 + int(bhour)*360 >> >>while True: >> act = time.localtime() >> actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*360 >> wait = bsec - actsec >> if wait < 0: >> wait += 360*24 # it will be tomorrow >> time.sleep(wait) >> print 'I am doing!' >> break > > Ah, very nice! (But all the '360's should be '3600', of course.) > > Thanks, Janos. > > Dick > > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
At 03:13 PM 2/29/2008, Dick Moores wrote: At 02:09 PM 2/29/2008, János Juhász wrote: > >import time >b = '20:00:00' > >(bhour, bmin, bsec) = b.split(':') >bsec = int(bsec) + int(bmin)*60 + int(bhour)*360 > >while True: > act = time.localtime() > actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*360 > wait = bsec - actsec > if wait < 0: > wait += 360*24 # it will be tomorrow > time.sleep(wait) > print 'I am doing!' > break Ah, very nice! (But all the '360's should be '3600', of course.) Also, there's no longer any need for the loop. So: = #!/usr/bin/env python #coding=utf-8 # KCTS.py import time, os timeStart = raw_input("Enter starting time as hh:mm:ss ") if timeStart == "": timeStart = "19:59:25" print "starting time set as", timeStart b = timeStart (bhour, bmin, bsec) = b.split(':') bsec = int(bsec) + int(bmin)*60 + int(bhour)*3600 act = time.localtime() actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*3600 wait = bsec - actsec if wait < 0: # startTime is in next day wait += 3600*24 print "wait is", wait time.sleep(wait) print 'Starting now' os.startfile('http://www.kuow.org/real.ram') = I wish I knew how to change that last line so that it would do what "E:\Programs\Real Player\realplay.exe" http://www.kuow.org/real.ram does at the command line--open Real Player at KUOW without calling my browser. Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help with encoder & decryption keys
Trey Keown wrote: > is it > possible to decompile things within a .pyc file? Yes, it is possible. There is a commercial service that will do this, for older versions of Python at least. To figure out a secret key kept in a .pyc file it might be enough to disassemble functions in the module; that can be done with the standard dis module. And of course if you stored the secrets as module globals all you have to do is import the module and print the value... Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Need help with encoder & decryption keys
"Trey Keown" <[EMAIL PROTECTED]> wrote > from being isolated, and messages being intercepted. So... is it > possible to decompile things within a .pyc file? Yes its definitely possible and in fact not even difficult - the tools come with Python. Do not do that if you want real security. Use a separate data file and put the encryption there. Alan G ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
At 02:09 PM 2/29/2008, János Juhász wrote: > > > I've got this so far: > > > > > > #!/usr/bin/env python > > > #coding=utf-8 > > > import time > > > b = '20:00:00' > > > while True: > > > a = time.strftime('%H:%M:%S') > > > time.sleep(0.5) > > > if a == b: > > > print "TIME!" > > > break > > > > >It needn't to make this comparison in every 0.5 seconds. >Calculate how long to sleep and ask that from the pc. > > >import time >b = '20:00:00' > >(bhour, bmin, bsec) = b.split(':') >bsec = int(bsec) + int(bmin)*60 + int(bhour)*360 > >while True: > act = time.localtime() > actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*360 > wait = bsec - actsec > if wait < 0: > wait += 360*24 # it will be tomorrow > time.sleep(wait) > print 'I am doing!' > break Ah, very nice! (But all the '360's should be '3600', of course.) Thanks, Janos. Dick ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Need help with encoder & decryption keys
Hey all, Been away for a while. So, I'm in the process of making a program for encrypting and decrypting strings of text. And I was wondering how it would be possible to perhaps keep keys in a .pyc file, and keep them from being isolated, and messages being intercepted. So... is it possible to decompile things within a .pyc file? This isn't for any serius project, just me attempting to make something to prove that I can do it. Thanks for any help. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to open IE7 to a certain URL?
> > I've got this so far: > > > > #!/usr/bin/env python > > #coding=utf-8 > > import time > > b = '20:00:00' > > while True: > > a = time.strftime('%H:%M:%S') > > time.sleep(0.5) > > if a == b: > > print "TIME!" > > break > > It needn't to make this comparison in every 0.5 seconds. Calculate how long to sleep and ask that from the pc. import time b = '20:00:00' (bhour, bmin, bsec) = b.split(':') bsec = int(bsec) + int(bmin)*60 + int(bhour)*360 while True: act = time.localtime() actsec = act.tm_sec + act.tm_min*60 + act.tm_hour*360 wait = bsec - actsec if wait < 0: wait += 360*24 # it will be tomorrow time.sleep(wait) print 'I am doing!' break Regards, Janos ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] authentication again a crm web application
hi everyone, I need to get pass throught an authentication form (username & password) to access our client CRM web application automaticaly, which means at some intervals of time i need to log in to thier web site download a specific table parse it & then load it into my mysql database. the parsing & loading part is already done, the part about authenticating is still in progress, any help would be very appreciated. the site uses https. thanks in advance. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] ANN: Beginner Python screencasts in 'developing emol!' ShowMeDo series
Summary - Erik Thompson is creating a long screencast series aimed at new Python programmers. You will learn to build a 3D Molecule Viewer, topics covered include Classes, Design, wxPython GUIs and pyOpenGL 3D graphics: http://showmedo.com/videos/series?name=vXJsRwlBX Detail - Currently at 14 episodes (with more to come) Erik shows you how he: * designs his application with Use Cases and Classes * uses Bazaar for source-code control * uses wxPython and pyOpenGL to create a 3D molecule viewer * bug fixes * uses the GPL and Copyright We have a total of 177 Python videos here: http://showmedo.com/videos/python?topic=all Please remember to *say Thank You* using the Comment form below the videos (or using the Quick Comments to the side of the videos) as Authors love to know that you appreciated their screencast. Alan - thanks for permission to post ANNounces. Regards, Ian Ozsvald (co-founder of ShowMeDo) -- http://Services.ShowMeDo.com http://ShowMeDo.com [EMAIL PROTECTED] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] iexplore scheduler
AIL PROTECTED]> Subject: Re: [Tutor] comparison bug in python (or do I not get it?) To: Kent Johnson <[EMAIL PROTECTED]>, Thomas Fischbacher <[EMAIL PROTECTED]> Cc: tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Hi Kent, > Hans Fangohr wrote: > >> In [2]: 2 in [1,2,3] == True >> Out[2]: False >> >> Why does [2] return False? Would people agree that this is a bug? > > No, not a bug. Don't be too quick to blame your tools! That's good news. I'd be worried if this wasn't the desired behaviour -- I just hadn't understood the logic. > > The equivalent expression is > In [1]: (2 in [1,2,3]) and ([1,2,3]==False) > Out[1]: False Ah -- that's the way to read it! > > 'in' is considered a comparison operator and can be chained with other > comparisons. For a clearer example, consider > In [2]: 2 < 3 < 4 > Out[2]: True > > which is not the same as > In [3]: 2 < (3 < 4) > Out[3]: False > > or > In [4]: (2 < 3) < 4 > Out[4]: True > > It is equivalent to > In [5]: (2 < 3) and (3 < 4) > Out[5]: True > Well explained -- makes perfect sense now. Many thanks, Hans > See > http://docs.python.org/ref/comparisons.html > > Kent > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > -- Hans Fangohr School of Engineering Sciences University of Southampton Phone: +44 (0) 238059 8345 Email: [EMAIL PROTECTED] http://www.soton.ac.uk/~fangohr -- Message: 8 Date: Fri, 29 Feb 2008 11:32:55 -0300 From: "Luciano Ramalho" <[EMAIL PROTECTED]> Subject: Re: [Tutor] comparison bug in python (or do I not get it?) To: "Kent Johnson" <[EMAIL PROTECTED]> Cc: Hans Fangohr <[EMAIL PROTECTED]>, tutor@python.org Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=ISO-8859-1 On Fri, Feb 29, 2008 at 10:21 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > No, not a bug. Don't be too quick to blame your tools! Well said, Kent. Here's a generic tip to anyone learning Python. I learned Python after working professionally with several languages for many years, including Java and Delphi, and I can say that Python is *very* well designed, is implemented with the highest standards of software engineering and caters to a rigorous and expert audience. It is **extremely** unlikely that you will ever find a bug in the interpreter or the built-ins if you are using a released version of Python. I've been using Python professionally since 1998 and I never stumbled upon a single bug anywhere in a released Python distribution. Of course, there are bugs and even security hot-fixes are issued from time to time. But I've never been affected by a Python bug in my projects. So it's better to assume that any strange behaviour is actually some misunderstanding on your part than a bug. Cheers, Luciano -- Message: 9 Date: Fri, 29 Feb 2008 06:58:57 -0800 From: Dick Moores <[EMAIL PROTECTED]> Subject: Re: [Tutor] How to open IE7 to a certain URL? To: Python Tutor List Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii" An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tutor/attachments/20080229/a37eafbc/attachm ent-0001.htm -- Message: 10 Date: Fri, 29 Feb 2008 07:06:19 -0800 From: Dick Moores <[EMAIL PROTECTED]> Subject: Re: [Tutor] How to open IE7 to a certain URL? To: Python Tutor List Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset="us-ascii"; format=flowed At 05:19 AM 2/29/2008, Tim Golden wrote: >Kent Johnson wrote: > > Dick Moores wrote: > > > >> #!/usr/bin/env python > >> #coding=utf-8 > >> import time > >> b = '20:00:00' > >> while True: > >> a = time.strftime('%H:%M:%S') > >> time.sleep(0.5) > >> if a == b: > > > > You might want to learn how to use your OS's scheduler to do this part. > > I don't know what it is on Windows though. > >You've got a couple of options on Windows, actually (not including >any roll-you-own or ported cron efforts). You can either use the >AT command The XP help says that rather than AT, to use schtasks. I'm trying to figure it out now.. > (from the command line or via WMI) Windows Management Instrumentation is a whole new world to me, but I understand (from Wikipedia) that XP has it. I wish you'd quit opening up these cans of worms! ;-) >or you can use the >Windows scheduler, either from the control panel or programatically >via the win32com.taskscheduler module from pywin32. Thanks again, Dick Moores -- ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor End of Tutor Digest, Vol 48, Issue 71 * ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
At 08:40 AM 2/29/2008, Chris Fuller wrote: >On Friday 29 February 2008 06:28, Dick Moores wrote: > > I keep missing a certain weekly program on my local NPR station. My > > idea is to record it using software I have, Easy Hi-Q Recorder. I can > > set it to start recording when the program starts, 8pm, but I need to > > have the program playing on my computer. The URL for the station's > > audio is http://www.kuow.org/real.ram . > > > > I've got this so far: > > > > #!/usr/bin/env python > > #coding=utf-8 > > import time > > b = '20:00:00' > > while True: > > a = time.strftime('%H:%M:%S') > > time.sleep(0.5) > > if a == b: > > print "TIME!" > > break > > > > Obviously, I need to replace the 'print "TIME"' line with something > > that will open IE7 to http://www.kuow.org/real.ram . But what? > > > > Thanks, > > > > Dick Moores > > > > ___ > > Tutor maillist - Tutor@python.org > > http://mail.python.org/mailman/listinfo/tutor > > >You might consider passing the URL directly to the audio player. This is >usually all the web browser does for you, although its possible there's a >different URL defined on that page each time, but then you could parse the >page in python using urllib and re, or something similar. Not only that, >launching IE7 is a time and memory consuming activity, and definitely lacks >grace. Yes. Point taken. >I dunno how your media player works, but this did the job for me (from the >command prompt): > >"c:\Program Files\Real Alternative\Media Player Classic\mplayerc.exe" >http://www.kuow.org/real.ram Great! "E:\Programs\Real Player\realplay.exe" http://www.kuow.org/real.ram works fine at the command prompt! >You could put this directly into your windows scheduler, and not use >python at >all. Start Menu>All Programs>Accessories>System Tools>Scheduled Tasks >You'll get an option to set the command line at the end of teh wizard, if you >check "show advanced options" > >You could have a python process running in the background that executed this >command through the subprocess module, at the appointed time. You could even >use something like FireDaemon to turn it into a service. But, it seems >better to use the windows scheduler. I'm having a lot of trouble with the windows scheduler. It wants a password, and there isn't one. In any event, I'd like to do this with Python, especially if I could have "a Python process running in the background." Would you mind giving me a start on the code for this? Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
"Kent Johnson" <[EMAIL PROTECTED]> wrote > You might want to learn how to use your OS's scheduler to do this > part. > I don't know what it is on Windows though. Start->Settings->Control Panel-Scheduled Tasks->Add New Task Starts a wizard. You can also try the 'at' command: -- C:\> help at The AT command schedules commands and programs to run on a computer at a specified time and date. The Schedule service must be running to use the AT command. AT [\\computername] [ [id] [/DELETE] | /DELETE [/YES]] AT [\\computername] time [/INTERACTIVE] [ /EVERY:date[,...] | /NEXT:date[,...]] "command" -- -- Alan Gauld Author of the Learn to Program web site Temorarily at: http://uk.geocities.com/[EMAIL PROTECTED]/ Normally: http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
On Friday 29 February 2008 06:28, Dick Moores wrote: > I keep missing a certain weekly program on my local NPR station. My > idea is to record it using software I have, Easy Hi-Q Recorder. I can > set it to start recording when the program starts, 8pm, but I need to > have the program playing on my computer. The URL for the station's > audio is http://www.kuow.org/real.ram . > > I've got this so far: > > #!/usr/bin/env python > #coding=utf-8 > import time > b = '20:00:00' > while True: > a = time.strftime('%H:%M:%S') > time.sleep(0.5) > if a == b: > print "TIME!" > break > > Obviously, I need to replace the 'print "TIME"' line with something > that will open IE7 to http://www.kuow.org/real.ram . But what? > > Thanks, > > Dick Moores > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor You might consider passing the URL directly to the audio player. This is usually all the web browser does for you, although its possible there's a different URL defined on that page each time, but then you could parse the page in python using urllib and re, or something similar. Not only that, launching IE7 is a time and memory consuming activity, and definitely lacks grace. I dunno how your media player works, but this did the job for me (from the command prompt): "c:\Program Files\Real Alternative\Media Player Classic\mplayerc.exe" http://www.kuow.org/real.ram You could put this directly into your windows scheduler, and not use python at all. Start Menu>All Programs>Accessories>System Tools>Scheduled Tasks You'll get an option to set the command line at the end of teh wizard, if you check "show advanced options" You could have a python process running in the background that executed this command through the subprocess module, at the appointed time. You could even use something like FireDaemon to turn it into a service. But, it seems better to use the windows scheduler. Cheers ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] comparison bug in python (or do I not get it?)
Kent Johnson wrote: > Hans Fangohr wrote: > >> In [2]: 2 in [1,2,3] == True On a slightly different tangent from the other answers you've received to this question, if you're using a conditional expression, don't compare it explicitly with True or False, just state the condition: if 2 in [1,2,3]: blah The same holds even if a variable contains True or False: some_option = True ... if some_option: blah NOT: if some_option == True: blah ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
At 05:19 AM 2/29/2008, Tim Golden wrote: >Kent Johnson wrote: > > Dick Moores wrote: > > > >> #!/usr/bin/env python > >> #coding=utf-8 > >> import time > >> b = '20:00:00' > >> while True: > >> a = time.strftime('%H:%M:%S') > >> time.sleep(0.5) > >> if a == b: > > > > You might want to learn how to use your OS's scheduler to do this part. > > I don't know what it is on Windows though. > >You've got a couple of options on Windows, actually (not including >any roll-you-own or ported cron efforts). You can either use the >AT command The XP help says that rather than AT, to use schtasks. I'm trying to figure it out now.. > (from the command line or via WMI) Windows Management Instrumentation is a whole new world to me, but I understand (from Wikipedia) that XP has it. I wish you'd quit opening up these cans of worms! ;-) >or you can use the >Windows scheduler, either from the control panel or programatically >via the win32com.taskscheduler module from pywin32. Thanks again, Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
At 05:07 AM 2/29/2008, Tim Golden wrote: Dick Moores wrote: > I keep missing a certain weekly program on my local NPR station. My > idea is to record it using software I have, Easy Hi-Q Recorder. I can > set it to start recording when the program starts, 8pm, but I need to > have the program playing on my computer. The URL for the station's > audio is http://www.kuow.org/real.ram . > > I've got this so far: > > #!/usr/bin/env python > #coding=utf-8 > import time > b = '20:00:00' > while True: > a = time.strftime('%H:%M:%S') > time.sleep(0.5) > if a == b: > print "TIME!" > break > > Obviously, I need to replace the 'print "TIME"' line with something > that will open IE7 to http://www.kuow.org/real.ram . But what? Sidestepping slightly, the natural way to open a URL using whatever's set up to do so is with os.startfile: import os os.startfile (" http://whatever...ram") I was going to say that, to use IE7 explicitly, you should use the webbrowser module. But then I realised that, for reasons which I'm sure are extremely good but which elude me for now, iexplorer is not one of the registered browsers. As a fallback, you can look for its apppath entry in the registry and use subprocess to call that. Turns out that os.startfile('http://www.kuow.org/real.ram') does the trick. (IE7 is my default browser.) So the script that will work is: == #!/usr/bin/env python #coding=utf-8 import time, os b = '20:00:00' while True: a = time.strftime('%H:%M:%S') #print a time.sleep(.5) if a == b: os.startfile('http://www.kuow.org/real.ram') break == Thanks! Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] comparison bug in python (or do I not get it?)
On Fri, Feb 29, 2008 at 10:21 AM, Kent Johnson <[EMAIL PROTECTED]> wrote: > No, not a bug. Don't be too quick to blame your tools! Well said, Kent. Here's a generic tip to anyone learning Python. I learned Python after working professionally with several languages for many years, including Java and Delphi, and I can say that Python is *very* well designed, is implemented with the highest standards of software engineering and caters to a rigorous and expert audience. It is **extremely** unlikely that you will ever find a bug in the interpreter or the built-ins if you are using a released version of Python. I've been using Python professionally since 1998 and I never stumbled upon a single bug anywhere in a released Python distribution. Of course, there are bugs and even security hot-fixes are issued from time to time. But I've never been affected by a Python bug in my projects. So it's better to assume that any strange behaviour is actually some misunderstanding on your part than a bug. Cheers, Luciano ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] comparison bug in python (or do I not get it?)
Hi Kent, > Hans Fangohr wrote: > >> In [2]: 2 in [1,2,3] == True >> Out[2]: False >> >> Why does [2] return False? Would people agree that this is a bug? > > No, not a bug. Don't be too quick to blame your tools! That's good news. I'd be worried if this wasn't the desired behaviour -- I just hadn't understood the logic. > > The equivalent expression is > In [1]: (2 in [1,2,3]) and ([1,2,3]==False) > Out[1]: False Ah -- that's the way to read it! > > 'in' is considered a comparison operator and can be chained with other > comparisons. For a clearer example, consider > In [2]: 2 < 3 < 4 > Out[2]: True > > which is not the same as > In [3]: 2 < (3 < 4) > Out[3]: False > > or > In [4]: (2 < 3) < 4 > Out[4]: True > > It is equivalent to > In [5]: (2 < 3) and (3 < 4) > Out[5]: True > Well explained -- makes perfect sense now. Many thanks, Hans > See > http://docs.python.org/ref/comparisons.html > > Kent > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > > > -- Hans Fangohr School of Engineering Sciences University of Southampton Phone: +44 (0) 238059 8345 Email: [EMAIL PROTECTED] http://www.soton.ac.uk/~fangohr ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
Kent Johnson wrote: > Dick Moores wrote: > >> #!/usr/bin/env python >> #coding=utf-8 >> import time >> b = '20:00:00' >> while True: >> a = time.strftime('%H:%M:%S') >> time.sleep(0.5) >> if a == b: > > You might want to learn how to use your OS's scheduler to do this part. > I don't know what it is on Windows though. You've got a couple of options on Windows, actually (not including any roll-you-own or ported cron efforts). You can either use the AT command (from the command line or via WMI) or you can use the Windows scheduler, either from the control panel or programatically via the win32com.taskscheduler module from pywin32. TJG ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] comparison bug in python (or do I not get it?)
Hans Fangohr wrote: > In [2]: 2 in [1,2,3] == True > Out[2]: False > > Why does [2] return False? Would people agree that this is a bug? No, not a bug. Don't be too quick to blame your tools! The equivalent expression is In [1]: (2 in [1,2,3]) and ([1,2,3]==False) Out[1]: False 'in' is considered a comparison operator and can be chained with other comparisons. For a clearer example, consider In [2]: 2 < 3 < 4 Out[2]: True which is not the same as In [3]: 2 < (3 < 4) Out[3]: False or In [4]: (2 < 3) < 4 Out[4]: True It is equivalent to In [5]: (2 < 3) and (3 < 4) Out[5]: True See http://docs.python.org/ref/comparisons.html Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
Dick Moores wrote: > #!/usr/bin/env python > #coding=utf-8 > import time > b = '20:00:00' > while True: > a = time.strftime('%H:%M:%S') > time.sleep(0.5) > if a == b: You might want to learn how to use your OS's scheduler to do this part. I don't know what it is on Windows though. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] How to open IE7 to a certain URL?
Dick Moores wrote: > I keep missing a certain weekly program on my local NPR station. My > idea is to record it using software I have, Easy Hi-Q Recorder. I can > set it to start recording when the program starts, 8pm, but I need to > have the program playing on my computer. The URL for the station's > audio is http://www.kuow.org/real.ram . > > I've got this so far: > > #!/usr/bin/env python > #coding=utf-8 > import time > b = '20:00:00' > while True: > a = time.strftime('%H:%M:%S') > time.sleep(0.5) > if a == b: > print "TIME!" > break > > Obviously, I need to replace the 'print "TIME"' line with something > that will open IE7 to http://www.kuow.org/real.ram . But what? Sidestepping slightly, the natural way to open a URL using whatever's set up to do so is with os.startfile: import os os.startfile ("http://whatever...ram";) I was going to say that, to use IE7 explicitly, you should use the webbrowser module. But then I realised that, for reasons which I'm sure are extremely good but which elude me for now, iexplorer is not one of the registered browsers. As a fallback, you can look for its apppath entry in the registry and use subprocess to call that. TJG ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] comparison bug in python (or do I not get it?)
Dear Python folks, here is a sequence of commands (ipython) that lead to a question. See my comments after leading '#': In [1]: 2 in [1,2,3] Out[1]: True #nothing special here, of course 2 is in the list. In [2]: 2 in [1,2,3] == True Out[2]: False #This is somewhat surprising, as one would hope that '2 in [1,2,3]' #evaluates to 'True', and then we expect 'True'=='True' to hold. #However, maybe it is an issue of operator precedence. Let's add parenthesis: In [3]: (2 in [1,2,3]) == True Out[3]: True #Okay, so this does what we expect. #However, if it is an issue of operator precedence, then what is the #operation that is carried out at prompt [2] above? # #Presumably, we work out In [4]: [1,2,3] == True Out[4]: False #which is false. So effectively, The statement at [2] seems to boil down to In [5]: 2 in False --- exceptions.TypeError Traceback (most recent call last) /Volumes/Minmax250a/Users2/fangohr/ TypeError: iterable argument required But this throws an error! And so does the full expression (with paranthesis): In [6]: 2 in ([1,2,3] == True) --- exceptions.TypeError Traceback (most recent call last) /Volumes/Minmax250a/Users2/fangohr/ TypeError: iterable argument required So what is the story here? In my view, the statement in line [2] should either produce True (as in [3]), or throw an error (as in [6]). Why does [2] return False? Would people agree that this is a bug? Thank you for your time, Hans PS I have tested this with Python 2.4, and Python 2.5 (on debian etch) -- Hans Fangohr School of Engineering Sciences University of Southampton Phone: +44 (0) 238059 8345 Email: [EMAIL PROTECTED] http://www.soton.ac.uk/~fangohr ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] How to open IE7 to a certain URL?
I keep missing a certain weekly program on my local NPR station. My idea is to record it using software I have, Easy Hi-Q Recorder. I can set it to start recording when the program starts, 8pm, but I need to have the program playing on my computer. The URL for the station's audio is http://www.kuow.org/real.ram . I've got this so far: #!/usr/bin/env python #coding=utf-8 import time b = '20:00:00' while True: a = time.strftime('%H:%M:%S') time.sleep(0.5) if a == b: print "TIME!" break Obviously, I need to replace the 'print "TIME"' line with something that will open IE7 to http://www.kuow.org/real.ram . But what? Thanks, Dick Moores ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor