Search code examples
pythonprogramming-languagesprogram-entry-point

why python doesn't have a main function?


Why python doesn't have a main function?

I mean, almost every language has a main function, including java:

public static void main(String[] args){}

c++:

int main(){}

Why python doesn't have one? Should we consider this as a good sign or bad sign? Should we consider this as an advantage or disadvantage?


Solution

  • Python is an interpreter that means it executes the code line by line from top, so it doesn't matter where the main() function is. An interpreter can be slower than a compiler but editing and changing the code is easier. You can find out more information of this here: https://www.programiz.com/article/difference-compiler-interpreter