Использование функции в функции
как в функцию:
def bubble_sort(the_list):
is_sorted = False
while not is_sorted:
is_sorted = True
for i in range(len(the_list)-1):
if the_list[i] > the_list[i+1]:
the_list[i], the_list[i+1] = the_list[i+1], the_list[i]
is_sorted = False
return the_list
вставить функцию:
def more_than(a,b, key=None):
if key is not None:
return key(a) > key(b)
return a > b
Источник: Stack Overflow на русском