how to bring out data out from def
Since path_f
is created inside the function, it belongs ONLY within the function(local variable), so what you can do is, make it global by saying global path_f
:
def browseFiles(): global path_f open_f = filedialog.askopenfile(mode='w', defaultextension='.xls') path_f = open_f.name print(path_f)
Now path_f
can be used anywhere within the code, given that it is defined before using it.
You can simply declare path_f
to be a global variable as follows:
def browseFiles(): global path_f open_f = filedialog.askopenfile(mode='w', defaultextension='.xls') path_f = open_f.name print (path_f)