[Python-Dev] getting at the current frame
Thu, 26 Oct 2000 01:09:44 -0700 (PDT)
On Tue, 24 Oct 2000, Barry A. Warsaw wrote:
> Okay, we all know that's a pain, right? Lots of people have proposed
> solutions. I've looked briefly at !?ng's Itpl.py, but I think it
> probably does too much by adding evaluation.
Do you think a variant of Itpl that only looked up variable names
would solve your problem?
> I can define _() to make the problem somewhat more convenient:
> def _(s):
> raise Exception
> except Exception:
> frame = sys.exc_info().tb_frame.f_back
> d = frame.f_globals.copy()
> return the_translation_of(s) % d
How about this routine to get the current frame: inspect.currentframe().
Could i humbly re-request approval for inspect.py in the standard library?
It's been up there for a long time, there's lots of good stuff in it,
and previous feedback on this list has all been fairly positive --
there just hasn't been an explicit approval for inclusion. This is
probably because we were busy trying to get 2.0 released (even though
inspect.py was proposed here before ascii.py, and ascii.py did get
I think the functionality it provides is important to supporting the
language definition. It abstracts away the special secret attributes
and protects us from future changes in the internals.
If there are changes that need to be made before it can be accepted,
i'd be happy to make them.