attaching someconfusing results in webbrowser.open on gnulinux
J. Cliff Dyer
jcd at sdf.lonestar.org
Thu Nov 1 08:56:34 EDT 2007
krishnakant Mane wrote:
> hello all,
> I had mentioned previously that I can't open html files in python.
> I have my username as krishna and there is a documents folder.
> so when I give webbrowser.open("file:///home/krishna/documents/tut.html")
> on python prompt I get true as return value but web browser (firefox )
> opens with page not found.
> and the address bar shows the following address which indeed is wrong.
> file:///home/krishna/"file:///home/krishna/documents/tut.html"
> I can't understand what is happening.
> regards,
> Krishnakant.
>
I haven't used the module, but it looks like webbrowser.open() is
treating your URL as a relative pathname instead. So it takes the
current working directory (/home/krishna/), and appends the relative
path you gave it (file:///home/krishna/documents/tut.html). Instead,
try calling:
webbrowser.open("documents/tut.html")
If that works, also try
webbrowser.open("/home/krishna/documents/tut.html")
I suspect both of those will work. There must be some other syntax for
opening URLs directly. Or maybe it interoperates with urllib.
Cheers,
Cliff
More information about the Python-list
mailing list