I really need webbrowser.open('file://') to open a web browser

Jon Clements joncle at googlemail.com
Sat Jan 16 18:20:02 CET 2010


On Jan 16, 5:08 pm, Jonathan Temple <jonntem... at googlemail.com> wrote:
> On Jan 15, 8:14 pm, Timur Tabi <ti... at freescale.com> wrote:
>
>
>
> > After reading several web pages and mailing list threads, I've learned
> > that the webbrowser module does not really support opening local
> > files, even if I use a file:// URL designator.  In most cases,
> > webbrowser.open() will indeed open the default web browser, but with
> > Python 2.6 on my Fedora 10 system, it opens a text editor instead.  On
> > Python 2.5, it opens the default web browser.
>
> > This is a problem because my Python script creates a local HTML file
> > and I want it displayed on the web browser.
>
> > So is there any way to force webbrowser.open() to always use an actual
> > web browser?
>
> > --
> > Timur Tabi
> > Linux kernel developer at Freescale
>
> Might not be useful, but trying open_new_tab() on...
>
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> import webbrowser as wb
> >>> x = wb.get()
> >>> x.basename
>
> 'gnome-open'
>
> When attempting to use open_new_tab(), I get:
>
> file:///home/jon/blahblah.html - opens in Firefox
> file:///home/jon/blahblah.txt  - opens in gedit
>
> Jon.

Err, I'd just like to mention that "Jonathan Temple" did not post that
message: He was checking his Google Mail on my machine, and when I
went to send my post, it got a little confused.

Cheers,

Jon.



More information about the Python-list mailing list