I've found a link to giving a very detailed and simple to understand explanation using the statement 'with' in python, and to summarise...Well if we use 'with', python will close the function that is called within the body of with. Say for an example using the in built function of open in Python, usually you will need to close that function. With 'with', Python does that for you. Simple.
with open("x.txt") as f:
  data = f.read()
  do something with data