We can run a Python module as a script directly. In order to do that it checks that “__name__” is set to “__main__”. If it is then it executes the code in the if block. See below for example.
- #imports here
- def run():
- #run code here
- return
- if __name__ == "__main__":
- run()