Python - Main (Entry Point)

1 - About

3 - Specification

4 - Type

4.1 - Package

4.1.1 - init

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

4.1.2 - 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': [

4.2 - Script

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.

5 - Documentation / Reference

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap