1

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.

dccsillag
  • 919
  • 4
  • 14
  • 25
  • at a guess it interprets "" as a filepath and thinks you want to open fileexplorer ... what would you expect to happen? – Joran Beasley May 04 '15 at 22:55

1 Answers1

1

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.

michaelpri
  • 3,521
  • 4
  • 30
  • 46