Я отправляю простой код, чтобы понять, как решить мою проблему. Цикл while имеет 2 цикла, но в реальном случае имеет миллиард циклов.Построен список функций
def uno_trov():
if(1==1):
return True
else:
return False
def due_trov():
if(1==0):
return True
else:
return False
condizioneV = []
condizione = [1, 0] #1 or 0 inside can be change by the user
first_time = False
i=0
while(i<2):
if(first_time == False): #whit the first cycle I build condizioneV (list of functions)
if(condizione[0]==1):
condizioneV.append(uno_trov)
if(condizione[1]==1):
condizioneV.append(due_trov)
first_time = True
print(condizioneV) #I expect [True]
i+=1
else: #second time condizioneV is already builded and I suppose the process will be more fast because the code not check anymore " if(condizione[1]==1)"
print(condizioneV) #I expect [True]
i+=1
#problem is that I obtain "[<function uno_trov at 0x0272DED0>]" two time.
Я не понимаю причины, но я получаю «[]» два раза. Это не ошибка, но у меня не было списка с одним или двумя True/False.
Вы добавляете _function_, а не _выполнение функции call_. Попробуйте 'condizioneV.append (uno_trov())'. –
Почему это вниз? –