Python - Main (Entry Point)

Card Puncher Data Processing


Language - (Main|Application Entry point) In Python.





def main():
    """Entry point for the application script"""
    print("Call your main application code here")

executable scripts

To provide executable scripts, use entry points in preference to the “scripts” keyword. Entry points provide cross-platform support and allow pip to create the appropriate form of executable for the target platform.

For example, the following would provide a command called sample which executes the function main from this package when invoked:

entry_points={  # Optional
        'console_scripts': [


When you want to make a script executable, the if statement makes that The code is not executed when the script is imported as a module.

import sys

def main(argv):
    # my code here

if __name__ == "__main__":

where __name__ has the value:

  • foo when the module is imported
  • or __main__ when executed from Python.

Documentation / Reference

Discover More
Card Puncher Data Processing
Python - Builtin Function

Builtin function are function that doesn't need an import statement. The builtins namespace associated with the execution of a code block is actually found by looking up the name __builtins__ in its...
Card Puncher Data Processing
Python - Script

in Python are source file that can be run. On Linux, begin your scripts with your interpreter. See or You can find them by executing the whereis commando: sys.argv[0] is the script name...

Share this page:
Follow us:
Task Runner