title: How to set BROWSER environmental variable for python webbrowser
body: <p>I'm trying to register the Firefox browser to run on Windows. According to the documentation for Webbrowser, "If the environment variable BROWSER exists, it is interpreted to override the platform default list of browsers, as a os.pathsep-separated list of browsers to try in order". I have the following:</p>
  
  <pre><code>import os
  import webbrowser
  from subprocess import call
  
  os.environ["BROWSER"] = "C:\\FirefoxPortable\\FirefoxPortable.exe"
  webbrowser.open('http://google.com')
  </code></pre>
  
  <p>This still opens iexplorer ( the default browser ).</p>
  
  <p>Also:</p>
  
  <pre><code>&gt;&gt;&gt; webbrowser._browsers
  {'windows-default': [&lt;class 'webbrowser.WindowsDefault'&gt;, None], 'c:\\program files\\internet explorer\\iexplore.exe': [None, &lt;webbrowser.BackgroundBrowser object at 0x04A18F90&gt;]}
  &gt;&gt;&gt; webbrowser._tryorder
  ['windows-default', 'C:\\Program Files\\Internet Explorer\\IEXPLORE.EXE']
  </code></pre>
  
  <p>How Can I use Firefox here?</p>
  
  <p>Source:</p>
  
  <pre><code># OK, now that we know what the default preference orders for each
  # platform are, allow user to override them with the BROWSER variable.
  if "BROWSER" in os.environ:
      _userchoices = os.environ["BROWSER"].split(os.pathsep)
      _userchoices.reverse()
  
      # Treat choices in same way as if passed into get() but do register
      # and prepend to _tryorder
      for cmdline in _userchoices:
          if cmdline != '':
              cmd = _synthesize(cmdline, -1)
              if cmd[1] is None:
                  register(cmdline, None, GenericBrowser(cmdline), -1)
      cmdline = None # to make del work if _userchoices was empty
      del cmdline
      del _userchoices
  
  # what to do if _tryorder is now empty?
  </code></pre>