Genshi - 如何打印范围内的所有变量

时间:2022-01-07 20:46:39

Quite simply I'd like to print out all variables that are in scope in my genshi template, as a debugging and discovery measure. Is there a way to do it?

很简单,我想打印出我的genshi模板中的所有变量,作为调试和发现度量。有办法吗?

1 个解决方案

#1


The standard Python function locals() (which returns a dict) works for me. I'm using Genshi 0.5.1, and as you'll see, everything seems to be in __data__.

标准的Python函数locals()(返回一个dict)对我有用。我正在使用Genshi 0.5.1,正如你所看到的,一切似乎都在__data__中。

${repr(locals())}

#1


The standard Python function locals() (which returns a dict) works for me. I'm using Genshi 0.5.1, and as you'll see, everything seems to be in __data__.

标准的Python函数locals()(返回一个dict)对我有用。我正在使用Genshi 0.5.1,正如你所看到的,一切似乎都在__data__中。

${repr(locals())}