"""template.py Author: Shahla Almasri (salmas1@cs.mcgill.ca) Created on: June 9, 2005 This module is an example of how to format your python code. For more detailed information, refer to http://www.python.org/peps/pep-0008.html and to http://moncs.cs.mcgill.ca/people/shahla/misc/PythonConventions.pdf. If there is a conflict between these two references, you should stick to the latter. You should organize your module in the following order: 1- imports 2- Global variables 3- Methods 4- Classes Variables: MY_VAR Describe the variable. Global variable names should be all capital letters. Methods: myFunc(myVar) A summary of what the function is for Classes: MyClass Here you put a one line summary of what the class is for. """ import os import sys from someModule import Module, AnotherModule MY_VAR = 77 def myFunc(myVar): """myFunc(float myVar) -> string Write a summary of what the function does. In our example, the description would be something like "Convert the absolute value of a number to a string." Parameters: myVar the number (integer/float) to convert Return: A string containing the absolute value of the given number """ return str(abs(myVar)) class MyClass: """This class is used as a template for future Python code written for MSDL. State here if your class inherits most of its functionality from another class. If that is the case then don't re-list the methods, just document what is different in your new class. You should organize your class in the following order: 1- Global variables 2- Constructor(s) 3- Public methods 4- Protected methods 5- Private methods Variables: var1 describe the variable var2 describe the variable Methods setMyTuple(var) Summary of what the function does getMyTuple() Summary of what the function does Interface: myFunction(myVar) Summary of what the function should do """ var1 = 10 # explain what the variable is for var2 = 'my variable' # explain what the variable is for def __init__(self, name, width, tpl=None): """MyClass(string name, float width, tuple tpl) Parameters: name string representing the title of the object width float represnting the width of the frame tpl tuple representing blah (default None) """ self.name = name self.width = width # you may want to explain what this variable is for self.__myTuple = tpl def setMyTuple(self, var=None): """setMyTuple(tuple var) Change the value of blah Parameters: var tuple containing the new value of blah (default None) """ self.__myTuple = var def getMyTuple(self): """getMyTuple() -> tuple Return a tuple representing blah """ return self.__myTuple def myFunction(self, myVar): """myFunction(list myVar) -> boolean Explain what the function does. If subclasses have to override this function then say so. Parameters: myVar describe the variable Return: True If ....... False Otherwise """ return True def __privateFunc(self, var): # __privateFunc(int var) -> MyClass # # Write a comment here describing the method, its parameters, # and its return value. None