I need to return the contents of a file, is it fine to do this :
def foo(filePath):
with open(filePath) as f:
return json.load(f)
Or should I do this instead :
def foo(filePath):
with open(filePath) as f:
r = json.load(f)
return r
(Of course my functions do other stuff, this is a toy model)