4 ms·
The main function, in C/CPP programs, satisfies an operating standard in Unix and Windows systems for a defined program instruction entry point. With CPython, m
by riazrizvi 6y ago
The main function, in C/CPP programs, satisfies an operating standard in Unix and Windows systems for a defined program instruction entry point. With CPython, main is written into the python executable's source. Python scripts are not C/CPP-source executables so they don't need a main, they don't need this constraint, so what sense is there in imposing it?
- im3w1l 6y agoNo, this isn't so. And besides, the main function isn't even the first thing in your program to run. The standard library does some setting up first. For instance populating argc and argv. You may enjoy reading this: http://www.muppetlabs.com/~breadbox/software/tiny/teensy.html http://www.muppetlabs.com/~breadbox/software/tiny/teensy.htm... It explains a lot of how linux loads programs. It's a bit dated though: everything is 32 bit.
- sszz 6y agoThere is definitely a main function in the CPython source code.
- nurettin 6y agoThe code to parse and populate commandline arguments comes from the linker, and is part of the generated binary, not the standard library. Here's a much better explanation https://embeddedartistry.com/blog/2019/04/08/a-general-overview-of-what-happens-before-main/ https://embeddedartistry.com/blog/2019/04/08/a-general-overv...