I'm working with arrays and I'm trying to create a function that returns or prints all the names of the functions of a class. I want to print it, but I get the same error
missing 1 required positional argument: 'self'
The code is:
import numpy as np
class Operation:
def __init__(self, array1, array2):
self.array1 = array1
self.array2 = array2
print("Input arrays:", array1, "and", array2)
def get_functions_names(self):
listofmethods = self.dir(Operation)[-2:]
return listofmethods
def element_wise_addition(self):
addition_result = self.array1 + self.array2
return addition_result
trial= Operation()
print(trial.get_functions_names())
Is it because I'm defining the two arrays in the constructor? Should I create a separate class?