How about:
class MyClass(object):
def __init__(self, filename):
self.filename = filename
self.stats = parse_file(filename)
def parse_file(filename):
#do some parsing
return results_from_parse
By the way, if you have variables named stat1
, stat2
, etc., the situation is begging for a tuple:
stats = (...)
.
So let parse_file
return a tuple, and store the tuple in
self.stats
.
Then, for example, you can access what used to be called stat3
with self.stats[2]
.