TEMPLATE
W/O ARGUMENTS
#!/usr/bin/env python3
def main() -> None:
"""Program execution entry point"""
print(12);
if __name__ == "__main__":
main();
* def = keyword used to define a function.
* main = the function’s name.
* (): the function takes no parameters.
* -> None: this is a type hint indicating that the function returns nothing.
* """ """ docstring (documentation string) for the main function.
- It describes what the function is for.
* a semicolon (;) is optional in Python and has no effect.
- A semicolon is not required in Python because the language does not use semicolons
to terminate statements. Instead, Python relies on newline characters and
indentation to define code structure. However, semicolons can still be used when
you want to place multiple statements on the same line. In Python, a semicolon
functions as a separator rather than a terminator, meaning it simply divides two
statements. This is why writing a semicolon at the end of a single statement is
still legal. It effectively creates a second, empty statement. Semicolons are most
commonly used when writing Python one-liners, allowing you to combine several
statements into a compact, single line of code.W/ ARGUMENTS
#######################################################################################
# Dev: cnd.dev
# Program Name: FileName-v1.0.0-linux-x86-64
# Version: 1.0.0
# - Major.Minor.Update
# Date: 181445MAR25
# Filename: filename.c
# Dependency: N/A
# Compile Cmd: gcc -m64 -O1 filename.c -o filename-v1.0.0-linux-x86-64
# Synopsis:
# - Overview: describes what the program does, how it works, and its key components
# - Technical: ...
#######################################################################################
#!/usr/bin/env python3
"""Simple Python script template"""
import argparse
def parse_args():
"""Handles command-line arguments"""
parser = argparse.ArgumentParser(description="Example script");
parser.add_argument("-f", "--file", help="Input file");
return parser.parse_args();
def main() -> None:
"""Program execution entry point"""
args = parse_args();
print(f"Target file: {args.file}");
if __name__ == "__main__":
main();
* The semicolon is rarely used in Python as a statement terminator, since Python
treats it as a statement separator rather than a required ending symbol. When a
semicolon appears at the end of a line, the interpreter processes it as an empty
statement, which has no effect. However, I find it helpful to include semicolons
in my code because it gives me a sense of familiarity and reinforces habits from
languages like C and C++, where semicolons are required to terminate statements.
Keeping the semicolon in my Python syntax helps maintain consistency in my
programming mindset and prevents me from forgetting how statements must be
terminated when switching between Python and lower-level languages such as C or C++.Last updated