Python中是否有类似的机制,就像set -x
对bash的影响一样?在
下面是bash在这种模式下的一些输出示例:
+ for src in cpfs.c log.c popcnt.c ssse3_popcount.c blkcache.c context.c types.c device.c ++ my_mktemp blkcache.c.o +++ mktemp -t blkcache.c.o.2160.XXX ++ p=/tmp/blkcache.c.o.2160.IKA ++ test 0 -eq 0 ++ echo /tmp/blkcache.c.o.2160.IKA + obj=/tmp/blkcache.c.o.2160.IKA
我知道Python ^{
要跟踪特定的调用,可以用自己的记录器包装每个有趣的函数。这会导致参数扩展为其值,而不仅仅是输出中的参数名。在
函数必须作为字符串传入,以防止模块重定向到其他模块的问题,例如操作系统路径/posixpath。我认为你不能仅仅从函数对象中提取正确的模块名来修补。在
包装代码:
用法:
^{pr2}$您应该尝试使用跟踪模块来获得更高的细节级别。 你到底需要什么?在
可能使用sys.settrace:
使用
traceit()
打开跟踪,使用traceit(False)
关闭跟踪。在收益率
^{pr2}$相关问题 更多 >
编程相关推荐