[python] -- interesting use of the webbrowser module

David Stockwell winexpert at hotmail.com
Thu Jun 10 20:37:25 CEST 2004


In the ongoing endeavor to learn python I started playing with the 
webbrowser module.

In this case I found an unorthodox way to launch an editor using the 
webbrowser.

Instance x just uses lynx to open a website.

instanze z however, opens an editor on a file.  I'm sure there are other 
ways to do it, I just saw it as a slightly different way to do this.

I guess what it really means is the 'open' simply launches the requested 
application and then that application does whatever it does.

One thing I did notice is that the 2nd launch doesn't occur until the first 
has completed. which makes each of these operations synchronous in nature.  
(no kwrite until lynx has closed).

code:
------------------ START CODE -----

import webbrowser as wb

x = wb.GenericBrowser('lynx %s')
z = wb.GenericBrowser('kwrite %s')

print "Opening instance X"
x.open('cellphone.duneram.com')

print "Opening instance Z"
z.open('/tmp/xyzabc')
-----------------  FIN DE CODE -------

David
-------
Tracfone: http://cellphone.duneram.com/index.html

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/





More information about the Python-list mailing list