I got some kind of problem with the structure with my code. I am using Tkinter and building a GUI. My idea is as follows: there is a field that takes the path to a file and when you click Start, Python opens the path and loads the file as a csv. Then it stores the file in a dict with some more information and returns the dict that will be passed around to other functions. However, how can this work? The Button can only run a function but not return something, right?
So I can enter the (partially filled) dict as an argument of this input function, however, it is never returned. My solution until now was to declare it a global, so when it is changed within the function, it is also changed outside. However, now I restructure the code and want to reuse code (since files are imported at several stages in the process). Now, when I want to use the same function again, the global solution seems problematic. Any ideas how I can do this without them? Thanks a lot.
Update1:
class Topclass:
def changer(x):
x += 1
class Subclass(Topclass):
def __init__(self):
self.b = 2
obb = Subclass()
print(obb.b)
Topclass.changer(obb.b)
print(obb.b)