Re:An exploration of why Python doesn't require a 'main' fun...
by riazrizvi on Tuesday July 21, 2020 @12:50PM
(#23908454)
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?
[ Parent
| on HN ]
Re:An exploration of why Python doesn't require a 'main' fun...
by im3w1l on Tuesday July 21, 2020 @01:13PM
(#23908701)
No, 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.htm... It explains a lot of how linux loads programs. It's a bit dated though: everything is 32 bit.
Re:An exploration of why Python doesn't require a 'main' fun...
by sszz on Tuesday July 21, 2020 @01:46PM
(#23909016)
There is definitely a main function in the CPython source code.
Re:An exploration of why Python doesn't require a 'main' fun...
by nurettin on Tuesday July 21, 2020 @11:12PM
(#23913552)
The 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-overv...