I have a class, like
class D:
def __init__(self):
"""some variables"""
def foo(self):
"""generates lots of data"""
I would like to be able to store all of the data that foo creates within the instance of the class that foo is being called from. Almost like creating a new initialization variable, but only once the method is called. For if the user never calls foo, no need to have generated the data to begin with.
Thanks!
foowhen the method is called the first time, and avoid those in subsequent calls by setting say a flag attribute.