Use the internal main function which gets automatically called when you run a python file, 

    if __name__ == "__main__":
       # do stuff here