User Tools

Site Tools


script:template

A template for writing Python code

template.py
"""
Python module template.
 
Author:  Tai Montgomery, Oct. 10, 2018
 
Triple quotes surround a docstring, which describes
the module or function in which it occurs.
 
For details:
https://docs.python.org/3.6/tutorial/controlflow.html#documentation-strings
"""
 
def my_function(number):
    """
    Describes function. This can include details about
    input, output, and/or arguments.
 
    """
    return number
 
if __name__ == '__main__':
    """
    This segment of the program is used for testing the code.
    It is automatically executed when you run the file as a script
    but not when it is imported as a module.
 
    For details, see:
    https://docs.python.org/3/library/__main__.html
 
    For a more in-depth explanation with examples, see:
    http://www.bogotobogo.com/python/python_if__name__equals__main__.php
    """
    n = 123
    print(my_function(n))
 
script/template.txt · Last modified: 2018/10/10 16:47 by dokuroot