function name

Peter Otten __peter__ at web.de
Thu Apr 29 09:37:15 CEST 2010


Steven D'Aprano wrote:

> Be aware though, that sys._getframe is marked as a private function (the
> leading underscore), which means that:
> 
> (1) It only exists in some Python implementations (CPython and possible
> nothing else?); and

$ jython
Jython 2.2.1 on java1.6.0_0
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> def f(): return sys._getframe().f_code.co_name
...
>>> f()
'f'

$ ipy
IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.1433
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import sys
>>> sys._getframe()
Traceback (most recent call last):
ValueError: _getframe is not implemented
>>> raise SystemExit # is there a sane way to quit ipy?

A quick websearch unearthed

http://blogs.msdn.com/dinoviehland/archive/2009/12/11/ironpython-2-6-
released.aspx

"""
IronPython 2.6 Released!

[...]

This release also changes how we support sys._getframe: a fully working 
version is now available by a command line option;  when not enabled 
sys._getframe doesn’t exist at all.
"""

Peter



More information about the Python-list mailing list