For this week's conversation, since we are talking about functions, most other programming languages have a main function. Python, on the other hand, does not have a main function unless we define it. Why does Python not have a main function

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

For this week's conversation, since we are talking about functions, most other programming languages have a main function. Python, on the other hand, does not have a main function unless we define it. Why does Python not have a main function

Expert Solution
Step 1
  • This is related both to linker and operating system behaviors and language design. C code is called directly (natively) by operating system, which has to know where to start among the many exported symbols.
  • If this is a library instead of an exe, the entry point can be any exported symbol (function) the calling program uses. If it is an exe, the OS follows a convention and calls a function with a particular name. On Unix in userland it is the main() function called by libc, in other environments it can be different: winmain() in windows, start_kernel() called by the bootload if it’s a Linux kernel started by the bootloader.
  • In the case of python, the language does not rely at all on OS called. The OS merely calls a program called “python” which then does whatever it likes, really it is translating some intermediate language to successive calls to C functions (coded inside the python software) with the right parameters.
  • That means the language designer had the possibility to do whatever he felt like to define the program workflow.

 

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education