#!/usr/bin/env python # import system modules # import os import sys # Class: Toaster # # This class facilitates handling a parameter file that controls # how many sweeps are done to generate a det curve. # class Toaster: # define a constructor # def __init__(self): print("... calling the default constructor...") self.height_d = [] self.width_d = float(27.0) self.length_d = float(0.0) self.models_d = [] # end of constructor # method: myprint # # arguments: none # # return: values are printed to stdout # def myprint(self, height = [], models = []): # set some variables # self.height_d = height self.models_d = models # print the data # print("height = ", self.height_d) print("width = ", self.width_d) print("length = ", self.length_d) print("models = ", self.models_d) # exit gracefully # return # end of function # method: myset # # arguments: height, width, length, model # # return: none # def myset(self, height = [], width = float(99.0), length = 99, model = []): print(">>>>", width) # set the data # self.height_d.append(height) self.width_d = width self.length_d = length self.models_d.append(model) # create another piece of internal data # self.joe_d = float(9999.999) # exit gracefully # return # end of function # method: debug # # arguments: none # # return: values are printed to stdout # def debug(self): return (self.width_d, self.length_d, self.models_d) # end of class # main program # def main(argv): # declare parameters # # C++ equivlent: Toaster joe; # toaster = Toaster() toaster1 = Toaster() # set some values # print("initialize toaster...") toaster.myprint(height = ["1", "2"]) print("-------------") myheight = []; toaster.myset(length = 27, width = float(5.0), height = myheight) print("toaster after myset...") toaster.myprint() #toaster.myset('Joe', float(-27), float(-99999), float(27.0)) #print("toaster after myset (2)...") #toaster.myprint() #toaster.myset(float(-2727), float(-1999), float(99), "cuisinart") #print("toaster after myset (3)...") #toaster.myprint() # another interesting way to call a function # #print("initalize toaster1...") #toaster1.myprint() #toaster1.myset(model = "XXXXX", width=float(-3.3333)) #print(" toaster1 after myset (1) 1...") #toaster1.myprint() print("... debug ...") x = toaster1.debug() print("x = ", x) _,x,_ = toaster1.debug() print("x = ", x) _,x,_ = toaster1.debug() print("x = ", x) ##print("x, y = ", x, y) print(toaster1.length_d) # begin gracefully # if __name__ == "__main__": main(sys.argv[0:]) # # end of file