我如何访问类的实例变量作为自己方法的默认参数? enter image description here
class DataAnalyst:
data = [1] # i want to acess this instance##########################
# def __init__(self,data):
# self.data = data
def medien(self,data = self.data):put it as a defult parametert#############
print("test",data)
data.sort()
index = len(data)
# this mean values of our data is odd number
if len(data) % 2 != 0:
return data[int(((index + 1) / 2 - 1))]
else:
num1 = data[int(((index / 2) - 1))]
num2 = data[int((index / 2))]
return (num1 + num2) / 2