Home > front end >  Is a lamda:function() inside the same function considered recursive?
Is a lamda:function() inside the same function considered recursive?

Time:10-21

I was watching this tutorial of how to make an image viewer:

https://www.youtube.com/watch?v=zg4c92pNFeo&t=1186s

Basically my question is if this part of code is considered recursive or not and why:

def forward(image_number):
    global my_label
    global button_forward
    global button_back

    my_label.grid_forget()
    my_label = tk.Label(image=image_list[image_number-1])
    button_forward = tk.Button(root, text=">>", command=lambda:forward(image_number 1))    #is this recursive?
    button_back = tk.Button(root, text="<<", command=lambda:back(image_number-1))

CodePudding user response:

No. forward does not call itself, directly or otherwise. It simply creates a button that can call forward at some point in the future. (I'm assuming that forward exits without actually triggering the button's callback function. If it did, I'd consider that somewhat of a gray area.)

  • Related