access variables of other functions
in python, how can i access the variables of one func开发者_运维技巧tion 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.
If you want to share data between functions then create a class and turn the functions into methods on the class.
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.
精彩评论