getting name of passed reference

Joel Davis callmeclaudius at gmail.com
Mon Dec 28 22:28:32 EST 2009


On Dec 28, 9:37 pm, Joel Davis <callmeclaud... at gmail.com> wrote:
> As far as more positive things are concerned, is anyone aware of what
> the support for _getframe(1) the way I used it is? Does steven have a
> newer (or older) version than me, maybe? (2.6.2) it seems like the
> sort of thing that ought to have pretty uniform behavior, but are
> their certain calls it varies on?

my thanks go out to Emile and Mr Hanson for their responses, I think
I've found the solution, much shorter as well:

    > #!/usr/bin/python

    > import traceback

    > def testing ( varPassed ):
    >         print traceback.extract_stack()[0][3]

    > testing("123")

and it seems the traceback module in general seems to have a lot of
history to it. This project is for CPython so compatibility with
Jython, Iron Python, et al isn't really that important right now. So
as far as functionality and compatibility I think I'm set as long as
traceback.extract_stack is 3.0 safe.



More information about the Python-list mailing list