Hello how are you guys!!!, In my previous post (Python + Eclipe Development Environment / Python Hello World ) you learned about development environment of python and eclipse. You also learned how to create "Hello, World!" application in python. Today you will learn about common python syntax such as commenting code in python and how to create a main script in python.
Python Main Function:
In the below screen shot you will notice a few things. First of all, at the very top, there is this line with a Pound sign, which is the Comment Indicator in Python and an exclamation point and then a path to the Python Interpreter. This is used in environments that run the script from a shell, UNIX-based environments like a Mac or Linux environment, and one of the beauties of a scripting language like Python is that your script can run in a number of different environments without change.
The code of main function in python is given below:
2. def main():
3. print("This is the main_function.py example.")
4. if __name__ == "__main__": main()
print("This is the main function.py example.")