Answer the question
In order to leave comments, you need to log in
How to access scope?
There are two functions: one is called by the second, is it possible to get access to the variables of the calling function from the called one?
def a():
### хочу получить x из функции b
def b(x):
return a()
Answer the question
In order to leave comments, you need to log in
import sys
def a():
j = 10
h = 20
b()
def b():
callingframe = sys._getframe(1)
print(callingframe.f_locals)
a()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question