I want to close f before returning from the method. I added finally blocked but it needs initialization. What to initialize it with?
def test_close_resource(url):
try:
f = urllib2.urlopen(url)
if f.code == 200:
return True
except Exception as error:
return False
finally:
f.close()