hi i have function which is called by tinker listbox
so i cannot return the value from it
basically i have a global object and i want to assign it inside a function
how can i do it
rlink = ('http://stackoverflow', 'pastbin.com', 'unix.com')
clink = ' '
# the function
def listbinding(*args):
idxs = reslinkbox.curselection()
idx = int(idxs[0])
clink = rlink[idx]
i want to rlink[idx] to assign to clink which is a global object
i cannot call the function, tkinter listbox calls the function so i cannot return clink from it
Use the
globalkeyword.<obligitory>Using globals like that is more often than not a bad idea as it smears your programs state all over the module rather than having it broken down into nice, discrete chunks. Preventing this is the whole purpose of name spaces. Many computer scientists have spent many years of hard, thankless work to bring you this knowledge.</obligitory>