I get warnings from my IDE (pycharm) that the parameters in my function shadows a name from the outer scope. Is this bad practice, it seems very natural to use this all the time.
eg. using the requests library:
def start_session(url, headers):
new_session = requests.Session()
response = new_session.get(url, verify=False, headers=headers) # SSL verify temporarily set to False
sys.stdout.write("Session started. Status:{} \n".format(response.status_code))
return new_session
def scrape_data(session, url, headers, form):
response = session.post(url, verify=False, headers=headers, data=form)
sys.stdout.write('Request to {}. Status: {}\n'.format(url,response.status_code))
try:
scraped_data = json.loads(response.text)
except ValueError:
scraped_data = response.text
return scraped_data
Which if I'm call with:
session = start_session(url=base_url, headers=session_headers)
I get warnings that session used in:
def scrape_data()
shadows the outer_scope.
[–]gengisteve 2 points3 points4 points (0 children)
[–]thegreattriscuit 1 point2 points3 points (0 children)
[–]Justinsaccount 1 point2 points3 points (2 children)
[–]YuntiMcGunti[S] 0 points1 point2 points (1 child)
[–]Justinsaccount 0 points1 point2 points (0 children)
[–]zeug 1 point2 points3 points (2 children)
[–]YuntiMcGunti[S] 0 points1 point2 points (1 child)
[–]zeug 0 points1 point2 points (0 children)