Here's an example for explaining my question a little better,
class T:
def fn(self):
rest = 'test'
return rest
def fn1(self):
print(rest)
I want to know, if there's any way that I can access the variable defined in functionfn
in function fn1
.
I looked around and I found that we could make variable global by passing global rest
in function fn
like below,In this way I was able to access rest variable in function fn1
def fn(self):
global rest
rest = 'test'
return rest
I want to know if there are any other way that I can access variables across multiple functions all belonging to same class.
Any help is really appreciated, Thanks.