How to get/set local variables of a function (from outside) in Python?

前端 未结 5 1368
误落风尘
误落风尘 2020-11-28 10:08

If I have a function (in Python 2.5.2) like:

def sample_func():
    a = 78
    b = range(5)
    #c = a + b[2] - x

My questions are:

5条回答
  •  忘掉有多难
    2020-11-28 10:53

    The function's locals change whenever the function is run, so there's little meaning to access them while the function isn't running.

提交回复
热议问题