Data Structures and Algorithms with Object-Oriented Design Patterns in Python
next up previous index

Static Methods

A static method   is a class attribute that does not require its first argument to be an instance of the class. (Normal methods require the first argument, self, to be a class instance).

   program57117
Program: Complex class __main__ method.

Program gif defines a main method for the Complex class. This method is a simple test program for the Complex class. For example, this static method can be invoked like this:

import sys

if __name__ == "__main__":
    sys.exit(Complex.main(*sys.argv))


next up previous index

Bruno Copyright © 2003, 2004 by Bruno R. Preiss, P.Eng. All rights reserved.