"""example.py Module docstring. example.py DoesSomething to infilename Producing outfilename Usage: example.py infileName outfileName Example: example.py in.txt out.txt """ class Simple: def __init__(self, str, str2): #the Simple constructor" # You must explicitly call any base-class constructor: # SimpleBass.__init__(self, str) # Two instance variables: self.s = str self.s2 = str2 # Four methods: def show(self): print (self.s) def show2(self): print (self.s2) def showMsg(self, msg): self.printTheMsg(msg) # Calling another method pm = self.printTheMsg # Make the method call shorter pm(msg) # Call the method again def printTheMsg(self, msg): print (msg) def main(argv=None): N_ARGS = 2 import sys if argv == None: argv=sys.argv args = argv[1:] #NOTE: args[0] != argv[0] == if len(args) != N_ARGS or "-h" in args or "--help" in args: print (__doc__) sys.exit(2) # Create an object: smp = Simple(args[0], args[1]) smp.showMsg('we did example.py to') smp.show() smp.showMsg('yielding') smp.show2() if __name__ == "__main__": sys.exit(main())