[Python-Dev] webbrowser.py

M.-A. Lemburg mal@lemburg.com
Tue, 23 Jan 2001 10:08:24 +0100

Ka-Ping Yee wrote:
> On Mon, 22 Jan 2001, Ka-Ping Yee wrote:
> > In trying to do the latter i've found the webbrowser module pretty
> > unreliable, by the way.  For example, it relies on a constant delay
> > of 4 seconds to launch a new browser that can't be expected on all
> > platforms, and fails to launch Netscape 3 because it supplies an
> > illegal command-line option.  When i've found good cross-platform
> > ways to make this work i'll suggest some patches.
> Oh, and i forgot to mention... i was pretty disappointed that:
>     setenv BROWSER my_browser_program
>     python -c 'import webbrowser; webbrowser.open("http://python.org/")'
> doesn't execute "my_browser_program http://python.org/" as i would
> have hoped.  Even for a known browser type:
>     setenv BROWSER lynx
>     python -c 'import webbrowser; webbrowser.open("http://python.org/")'
> does not work as expected, either.  (Red Hat Linux here.)

Hmm, lynx should work (the module has explicit support for it)
and yes, I agree, webbrowser should trust BROWSER and use a
generic calling mechanism (program <url>) for opening the

Too late for 2.1a1, but maybe for a2 ?!

BTW, I think that the second line here is causing the problem:

class CommandLineBrowser:
    _browsers = [] # <- this overrides the global of the same name
    if os.environ.get("DISPLAY"):
            ("netscape", "netscape %s >/dev/null &"),
            ("mosaic", "mosaic %s >/dev/null &"),
        ("lynx", "lynx %s"),
        ("w3m", "w3m %s"),

Marc-Andre Lemburg
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/