I need help in modifying my program. Right now it looks as follows:
class Filedict(): def __init__(self, fname): self.fname =fname def parse(self): with open(self.fname, 'r') as f: .... # some file search and parsing logic return parsed_file def process(self, parsed_object): for k in parsed_obj.keys(): .... return processed_file I instantiate Filedict and use it as follows: f = Filedict('sales.txt') parsed_f = f.parse() processed_f = f.process(parsed_f) So I need to pass parsed_f again to the process method. I would like to use process method directly on initialized object. For example: f = Filedict('sales.txt') f.process() Can someone help me in improving my code? Should I store parsed_file as an object attribute as follows? class Filedict(): def __init__(self, fname): self.fname =fname self.parsed_file = self.parse() Any help? -Jm
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor