python中sys._getframe() 是要怎么样的环境才有

CPython和PyPy都是支持的,但是还有IronPython、Jython等等不同的解释器,这个只是CPython导入的用于内部功能(比如inspect、traceback可能会用)的接口,其他解释器中,inspect和traceback的功能会跟文档一致,但不一定也是用_getframe实现,所以最好是调用那些库
■网友
Oh my, just run the function and catch the exception. Don\u0026#39;t you know what exception is used for?
■网友
下划线开头的成员属于“具体的实现细节”吧,这种不属于外部接口的东西,将来有可能被去除或者改换名字。
■网友
你再看这一句:CPython implementation detail: The gettrace() function is intended only for implementing debuggers, profilers, coverage tools and the like. Its behavior is part of the implementation platform, rather than part of the language definition, and thus may not be available in all Python implementations.也就是说,python 在不同的平台可能有不同的实现,不保证每种实现都有这种方法,与平台支持等有关系。


    推荐阅读