dccsillag
dccsillag

Reputation: 957

Python: webbrowser.open("") opens a file explorer window

I'm coding a very simple url opener that gets the url in the terminal window (using input) and opens it with webbrowser.open.

The problem is that when nothing is put into the input (it's run webbrowser.open("")), a file explorer window appears instead of my web browser, and when I put something in the input, for example, http://www.google.com (it's run webbrowser.open("http://www.google.com")) it correctly opens google chrome. What's happening?

I'm running python 3.2.2 on windows 8, AMD. Thanks in any advance.

Upvotes: 1

Views: 936

Answers (1)

michaelpri
michaelpri

Reputation: 3651

Well, on the Python webpage for the webbrowser module, under webbrowser.open(), it says

Note that on some platforms, trying to open a filename using this function, may work and start the operating system’s associated program.

Your computer realizes that you aren't trying to open a URL, so it attempts to open a file instead and because there is no input, it just opens your file explorer.

Upvotes: 1

Related Questions