python 获取当前函数名和行号
2015-07-03 11:23
741 查看
sys._getframe([depth])
Return a frame object from the call stack. If optional integer depth is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, ValueError is
raised. The default for depth is zero, returning the frame at the top of the call stack.
CPython implementation detail: This function should be used for internal and specialized purposes only. It is not guaranteed to exist in all implementations of Python.
<span style="font-family:Arial;font-size:18px;"><strong>sys._getframe(1).f_code.co_name
sys._getframe().f_back.f_code.co_name</strong></span>
Return a frame object from the call stack. If optional integer depth is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, ValueError is
raised. The default for depth is zero, returning the frame at the top of the call stack.
CPython implementation detail: This function should be used for internal and specialized purposes only. It is not guaranteed to exist in all implementations of Python.
<span style="font-family:Arial;font-size:18px;"><strong>sys._getframe(1).f_code.co_name
sys._getframe().f_back.f_code.co_name</strong></span>
相关文章推荐
- Python中map()函数浅析
- Berkeley's SICP in python(一)
- Python学习之五【程序控制结构-选择结构&&循环结构】
- pythond多线程——生产消费者模型
- 算法导论习题(python)Chapter One
- python列表推导式-轻量级循环
- Python中kill传送程序 signal HUP信号 程序重载配置文件
- eclipse中运行python脚本中有注释为中文的内容,报错:SyntaxError: Non-ASCII character '\xe5'
- python six
- python的沙盒环境virtualenv(二)--简单使用
- python的沙盒环境virtualenv(一)--作用
- python插入排序算法实例分析
- python列出目录下指定文件与子目录的方法
- Python学习之四【变量】
- python中使用中文
- python中的协程
- (转)Django vs Flask vs Pyramid: Choosing a Python Web Framework
- [转载] 每个 Python 程序员都要知道的日志实践
- Python学习笔记(1)
- django(Python Web 框架)