[Python-Dev] [Python-checkins] r83890 - python/branches/py3k/Lib/inspect.py (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Mon Aug 9 16:29:44 CEST 2010
- Previous message: [Python-Dev] r83885 - in python/branches/py3k: Lib/re.py Lib/test/test_re.py Misc/NEWS
- Next message: [Python-Dev] [Python-checkins] r83890 - python/branches/py3k/Lib/inspect.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Aug 9, 2010 at 11:05 PM, benjamin.peterson <python-checkins at python.org> wrote:
-if hasattr(sys, 'getframe'): - currentframe = sys.getframe -else: - currentframe = lambda =None: None +def currentframe(): + """Return the frame or the caller or None if this is not possible.""" + return sys.getframe(1) if hasattr(sys, "getframe") else None
It isn't hugely important, but with sys._getframe() unlikely to appear during runtime, the following may make more sense:
if hasattr(sys, '_getframe'): def currentframe(): return sys._getframe(1) else: def currentframe(): pass currentframe.doc = "Return the frame of the caller or None if this is not possible."
(Oh, and there's a typo in the docstring...)
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] r83885 - in python/branches/py3k: Lib/re.py Lib/test/test_re.py Misc/NEWS
- Next message: [Python-Dev] [Python-checkins] r83890 - python/branches/py3k/Lib/inspect.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]