def callers(self, n=4, count=0, excludeCaller=True, files=False):
'''Return a list containing the callers of the function that called g.callerList.
If the excludeCaller keyword is True (the default), g.callers is not on the list.
If the files keyword argument is True, filenames are included in the list.
'''
# sys._getframe throws ValueError in both cpython and jython if there are less than i entries.
# The jython stack often has less than 8 entries,
# so we must be careful to call g._callerName with smaller values of i first.
result = []
i = 3 if excludeCaller else 2
while 1:
s = self._callerName(i, files=files)
# print(i,s)
if s:
result.append(s)
if not s or len(result) >= n: break
i += 1
result.reverse()
if count > 0: result = result[: count]
sep = '\n' if files else ','
return sep.join(result)
评论列表
文章目录