开发者

access variables of other functions

开发者 https://www.devze.com 2022-12-27 17:21 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号