What is main function in python? How do you invoke it?
Python | Main Function
In the world of programming languages, the main is considered as an entry point of execution for a program. But in python, it is known that the interpreter serially interprets the file line-by-line. This means that python does not provide main() function explicitly. But this doesn't mean that we cannot simulate the execution of main. This can be done by defining the user-defined main() function and by using the __name__ property of the python file. This __name__ variable is a special built-in variable that points to the name of the current module. This can be done as shown below:
def main(): print("This is main function!") if __name__=="__main__": main()