Reputation: 2959
in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me.
can someone help me, how to access the variables from one function to another function.
Upvotes: 0
Views: 1705
Reputation: 599630
Don't try to do this. Explicit is better than implicit - if your function needs access to certain variables, pass them in. If it needs to change a value in the calling function, return the new value.
Upvotes: 0
Reputation: 26552
If you want to share data between functions then create a class and turn the functions into methods on the class.
Upvotes: 1