mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
26 lines
463 B
Python
26 lines
463 B
Python
import sys
|
|
|
|
value = 189
|
|
locals_dict = sys._getframe().f_locals
|
|
assert locals_dict["value"] == 189
|
|
foo = "bar"
|
|
assert locals_dict["foo"] == foo
|
|
|
|
|
|
def test_function():
|
|
x = 17
|
|
assert sys._getframe().f_locals is not locals_dict
|
|
assert sys._getframe().f_locals["x"] == 17
|
|
assert sys._getframe(1).f_locals["foo"] == "bar"
|
|
|
|
|
|
test_function()
|
|
|
|
|
|
class TestClass:
|
|
def __init__(self):
|
|
assert sys._getframe().f_locals["self"] == self
|
|
|
|
|
|
TestClass()
|