从 Python 访问 Hy 中定义的带有斜杠或星号的属性和方法名称
Access attribute and method names with slashes or asterisks defined in Hy from Python
如果我要执行以下操作:
(setv a/b 12)
我如何访问 Python 中的变量,例如从常规 python 模块,或者简单地使用 (py)
?
(py "print(a/b)")
与mangling:
=> (setv a/b 12)
=> a/b
12
=> (hy.mangle "a/b")
"hyx_aXsolidusXb"
=> hyx_aXsolidusXb
12
=> (py "print(hyx_aXsolidusXb)")
12
=> (py "print(globals()[hy.mangle('a/b')])")
12
如果我要执行以下操作:
(setv a/b 12)
我如何访问 Python 中的变量,例如从常规 python 模块,或者简单地使用 (py)
?
(py "print(a/b)")
与mangling:
=> (setv a/b 12)
=> a/b
12
=> (hy.mangle "a/b")
"hyx_aXsolidusXb"
=> hyx_aXsolidusXb
12
=> (py "print(hyx_aXsolidusXb)")
12
=> (py "print(globals()[hy.mangle('a/b')])")
12