本文整理汇总了Python中mx.Tools.tuples方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.tuples方法的具体用法?Python Tools.tuples怎么用?Python Tools.tuples使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mx.Tools
的用法示例。
在下文中一共展示了Tools.tuples方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print_stack
# 需要导入模块: from mx import Tools [as 别名]
# 或者: from mx.Tools import tuples [as 别名]
def print_stack(file=_sys.stdout,levels=100,offset=0,locals=0):
# Prepare frames
try:
raise ValueError
except ValueError:
# Go back offset+1 frames...
f = _sys.exc_info()[2].tb_frame
for i in range(offset + 1):
if f.f_back is not None:
f = f.f_back
# Extract frames
frames = []
while f:
frames.append(f)
f = f.f_back
frames.reverse()
# Prepare stack
stack = _traceback.extract_stack()
# Make output
file.write('Stack:\n')
for (frame,(filename, lineno, name, line)) in \
Tools.tuples(frames,stack)[-levels:]:
file.write(' File "%s", line %d, in %s\n' % (filename,lineno,name))
if line:
file.write(' %s\n' % line.strip())
if locals:
print_frame_locals(frame,file,indent=' |',title='')
示例2: objects
# 需要导入模块: from mx import Tools [as 别名]
# 或者: from mx.Tools import tuples [as 别名]
def objects(self,constructor):
""" Builds a list of objects by calling the given constructor
with keywords defined by mapping column names to values for
each input line.
.columns must have been set using .set_columns() or by
processing a given CSV header.
"""
lines = self.lines
keys = self.columns
if keys is None:
raise Error,'no columns set'
objs = [None] * len(lines)
for i,line in Tools.irange(lines):
kws = dict(Tools.tuples(keys, line))
objs[i] = apply(constructor,(),kws)
return objs