Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
webbrowser.open( )
-
Shouldn't the following code open a web browser?
import webbrowser url = 'www.yahoo.com' webbrowser.open(url)
-
The URL needs to start with a protocol (usually
http://
orhttps://
), otherwise nothing happens (althoughTrue
is returned). -
Note that "http", "https" and "file" open in the built-in browser, which seems fairly useless if you are building a stand-alone app. You have to use "safari-" at the start of the protocol to open in Safari.
Wish there was an option for webbrowser.open to leave it for the OS to open, regardless of the URL.
-
@mikael - thank you for the additional information regarding the Safari URL scheme. I understand your opinion about the use of the built in browser and I agree. I normally would create my own browser or launch in Safari as you mentioned.
However, actually I have found it quite nice to have the webbrowser module if your stand alone app needs to display documentation, certain media, etc.