Dec-22-2017, 09:42 AM
Hi All,
--------------
class Xyz(object):
Hi All,
I want to save mutliple method output to a global file so that I can use it in another method. I am able to the output when I run sigle method. However output is over writing when I run mutliple methods at same time. My code looks like this,
I want to save method1 & 2 output to output_file and use it in mothod3. Could you please suggest how I can achieve this? Thanks in advance.
--------------
class Xyz(object):
Hi All,
I want to save mutliple method output to a global file so that I can use it in another method. I am able to the output when I run sigle method. However output is over writing when I run mutliple methods at same time. My code looks like this,
class Abc(object): def __init__(self, net, cost): self.net = net self.cost = cost self.output_file = None def method1(self): self.output_file = list() input = {'Class': 1, 'Range': 'top'} output_file.append(input) def method2(self): #self.output_file = list() input = {'Class': 2, 'Range': 'low'} output_file.append(input) def method3(self): for line in self.output_file: print line
I want to save method1 & 2 output to output_file and use it in mothod3. Could you please suggest how I can achieve this? Thanks in advance.