[Tutor] How to print the installed web browser

Alan Gauld alan.gauld at btinternet.com
Thu Sep 2 02:02:08 CEST 2010

"Steve Willoughby" <steve at alchemy.com> wrote

>> Not perfect, but you could check for each browser's binary.
>> import os
>> os.path.isfile("/usr/bin/firefox")

But then you have to know of all browsers and thats almost impossible.
And what if the user has built their own browser - I've written at 
3 web browsers of varying quality over the years! Including one batch
oriented one that ran overnight in the days when I only had a
14400 baud modem connection...

> You'd probably be better off at least looking at the user's PATH 
> variable, which would likely catch platform variations in where the 
> browser would be located, and catch local installations by that 
> user.

But only if they used path.
When I was a Unix user I used to just set up aliases to many of
the binaries that I installed locally. Or I would use a shell script 
launch them after setting up environment variables etc. The shell
script would be in my PATH but not the binary...

It really is an impossible task to get right. The best you will get is
a check against a small set of the most common browsers

firefox, opera, konqueror, chrome, lynx, safari(is it on Linux?) etc.

And as Steven pointed out many office type programs include the
ability to act as a basic browser nowadays. Even trhe Eclipse IDE
can display HTML pages. Does that count?

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list