#!/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 static varaible # dbgl_d = True # 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): # create a set # thisset = {"apple", "banana", "cherry"} print(thisset) print(type(thisset)) # delcare list with duplicate elements: fruitList = ["banana", "orange", "apple", "peach", "apple"] print("original list:\n", fruitList) # first convert list into set fruitList = set(fruitList) # now convert set back into list fruitList = list(fruitList) print("list without duplicates and altered order:\n", fruitList) # create two toasters # t1 = Toaster() t2 = Toaster() # print the values before # print(t1.dbgl_d, t2.dbgl_d) # set the value # Toaster.dbgl_d = False # print the values after # print(t1.dbgl_d, t2.dbgl_d) # begin gracefully # if __name__ == "__main__": main(sys.argv[0:]) # # end of file