views:

101

answers:

2

hi, 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.

+1  A: 

If you want to share data between functions then create a class and turn the functions into methods on the class.

Dave Kirby
thanks buddy, i got it.
Suhail
A: 

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.

Daniel Roseman
hi daniel, can you give some example, because i am once again stuck in an another project, and i don't have enough time to recode the whole project left by my senior, can you please help me with some example.
Suhail