• <tfoot id='zkjgK'></tfoot><legend id='zkjgK'><style id='zkjgK'><dir id='zkjgK'><q id='zkjgK'></q></dir></style></legend>

        • <bdo id='zkjgK'></bdo><ul id='zkjgK'></ul>
        <i id='zkjgK'><tr id='zkjgK'><dt id='zkjgK'><q id='zkjgK'><span id='zkjgK'><b id='zkjgK'><form id='zkjgK'><ins id='zkjgK'></ins><ul id='zkjgK'></ul><sub id='zkjgK'></sub></form><legend id='zkjgK'></legend><bdo id='zkjgK'><pre id='zkjgK'><center id='zkjgK'></center></pre></bdo></b><th id='zkjgK'></th></span></q></dt></tr></i><div id='zkjgK'><tfoot id='zkjgK'></tfoot><dl id='zkjgK'><fieldset id='zkjgK'></fieldset></dl></div>

        <small id='zkjgK'></small><noframes id='zkjgK'>

        inspect.currentframe() 在某些实现下可能不起作用?

        inspect.currentframe() may not work under some implementations?(inspect.currentframe() 在某些实现下可能不起作用?)
        <i id='wDkg3'><tr id='wDkg3'><dt id='wDkg3'><q id='wDkg3'><span id='wDkg3'><b id='wDkg3'><form id='wDkg3'><ins id='wDkg3'></ins><ul id='wDkg3'></ul><sub id='wDkg3'></sub></form><legend id='wDkg3'></legend><bdo id='wDkg3'><pre id='wDkg3'><center id='wDkg3'></center></pre></bdo></b><th id='wDkg3'></th></span></q></dt></tr></i><div id='wDkg3'><tfoot id='wDkg3'></tfoot><dl id='wDkg3'><fieldset id='wDkg3'></fieldset></dl></div>
            <legend id='wDkg3'><style id='wDkg3'><dir id='wDkg3'><q id='wDkg3'></q></dir></style></legend>

          • <tfoot id='wDkg3'></tfoot>

            <small id='wDkg3'></small><noframes id='wDkg3'>

              <tbody id='wDkg3'></tbody>

              <bdo id='wDkg3'></bdo><ul id='wDkg3'></ul>

                • 本文介绍了inspect.currentframe() 在某些实现下可能不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  根据文档:

                  inspect.currentframe()

                  返回调用者堆栈的框架对象框架.

                  Return the frame object for the caller’s stack frame.

                  CPython 实现细节:此函数依赖于 Python 堆栈解释器中的框架支持,不保证存在于Python的所有实现.如果在没有的实现中运行Python栈帧支持这个函数返回None.

                  CPython implementation detail: This function relies on Python stack frame support in the interpreter, which isn’t guaranteed to exist in all implementations of Python. If running in an implementation without Python stack frame support this function returns None.

                  为什么只有这个函数被标记为依赖于实现"?如果这个功能不起作用,是不是类似的功能,如inspect.traceinspect.stack等也无法使用?

                  How is it that only this function is marked as "implementation-dependent"? If this function doesn't work, wouldn't similar functions, such as inspect.trace, inspect.stack, etc. also be unavailable?

                  另外,堆栈框架支持"是什么意思,为什么它会不存在?

                  Also, what does "stack frame support" mean, and why would it ever be absent?

                  推荐答案

                  在自己寻找答案时偶然发现了这个问题.inspect.currentframe 的可用性与 sys._getframe 相关:

                  Stumbled upon this question while looking for the answer myself. The availability of inspect.currentframe is tied to sys._getframe:

                  def currentframe():
                      """Return the frame of the caller or None if this is not possible."""
                      return sys._getframe(1) if hasattr(sys, "_getframe") else None
                  

                  因此,该限制适用于所有其他也使用 sys._getframe 的函数.对于 inspect,这只是 inspect.stack.

                  The restriction thus applies to all other functions also using sys._getframe. For inspect, this is only inspect.stack.

                  相比之下,inspect.trace 使用 sys.exc_info.这是异常处理方案的一个组成部分,并且应该始终可用.所有其他相关功能,例如getframeinfo,已经依赖有一个框架.它们的适用性取决于您是要检查异常还是要调用回溯.

                  In contrast, inspect.trace uses sys.exc_info. This is an integral part of exception handling schemes, and should always be available. All other related function, e.g. getframeinfo, already rely on there being a frame. Their applicability depends on whether you want to inspect an exception or call traceback.

                  请注意,我的本地默认 jython 确实支持 sys._getframe.如果使用 -X:Frames 运行,ipy 可以工作.

                  Note that my local, default jython does support sys._getframe. ipy works if run with -X:Frames.

                  这篇关于inspect.currentframe() 在某些实现下可能不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                  1. <i id='bKlvW'><tr id='bKlvW'><dt id='bKlvW'><q id='bKlvW'><span id='bKlvW'><b id='bKlvW'><form id='bKlvW'><ins id='bKlvW'></ins><ul id='bKlvW'></ul><sub id='bKlvW'></sub></form><legend id='bKlvW'></legend><bdo id='bKlvW'><pre id='bKlvW'><center id='bKlvW'></center></pre></bdo></b><th id='bKlvW'></th></span></q></dt></tr></i><div id='bKlvW'><tfoot id='bKlvW'></tfoot><dl id='bKlvW'><fieldset id='bKlvW'></fieldset></dl></div>
                      <bdo id='bKlvW'></bdo><ul id='bKlvW'></ul>
                      <tfoot id='bKlvW'></tfoot>
                        • <small id='bKlvW'></small><noframes id='bKlvW'>

                            <tbody id='bKlvW'></tbody>
                        • <legend id='bKlvW'><style id='bKlvW'><dir id='bKlvW'><q id='bKlvW'></q></dir></style></legend>