I am iterating a list of links for screen scraping.  The pages have JavaScript so I use Selenium.  I have a defined a function to get the source for each page.

Should I instantiate the WebDriver inside that function, which will happen once per loop?
Or should I instantiate outside the function and pass the WebDriver in?
Or assign the WebDriver to a variable that will be visible from inside the function, without explicitly passing it?
Each instantiation of WebDriver launches a new browser, which is a very costly operation, so option 1 is not what you want to do. 
I would also not do option 3 because it is not good coding practice to depend on global variables when it can easily be avoided. 
This leaves you option 2: instantiate WebDriver once and pass the instance to your function(s).
Where should I instantiate my WebDriver instance when looping?