#coding:utf-8
def my_sum(*arg):
return sum(arg)
def my_average(*arg):
print('in my_sum')
return sum(arg)/len(arg)
def dec(func):
def in_dec(*arg):#my_sum
print('in dec arg=',arg)
if len(arg) ==0:
return 0
for val in arg:
if not isinstance(val,int):
return 0
return func(*arg)
return in_dec
#my_sum=dec(my_sum)
#dec return in_dec ->my_sum
my_sum=dec(my_sum)
my_average=dec(my_average)
print(my_sum(1,2,3,4,5))
print(my_sum(1,2,3,4,5,6))
print(my_average(1,2,3,4,5))
print(my_average)
精慕门9075571
相关分类