In the last 6 months, I have created many classes and function for different calculations. Now I would like to join them into a class so it could be used by other users. Like many of the methods can be performed in sequence and the sequence may require to be run multiple times for different sets of data. I would like to create a function within the main class that saves the procedure used by the user so the user could run it again without going through the whole procedure again.
Important: I would not like to change the classes that have already been implemented, but if this is the only way, no problem.
The idea would be more or less like the code represented below:
class process(object):
def __init__(self):
self.procedure = []
def MethodA(valueA):
pass
def MethodB(valueB):
pass
def UpdateProcedure(self, method, arguments, values):
# Execute this every time that MethodA or MethodB is executed.
new = {'Method':method, 'Arguments':arguments, 'Values':values}
self.procedure.append(new)
For example:
a = process.MethodA(2)
b = process.MethodB(3)
print(process.procedure)
>>> [{'Method':'MethodA', 'Arguments':['valueA'], 'Values':[2]}, {'Method':'MethodB', 'Arguments':['valueB'], 'Values':[3]}]
I have tried to use the functions inspect.currentframe
and __getattribute__
together, but I did not get good results.
Any ideas to help me with this issue?
Thanks