Return name of caller function?
Matthew Peter
survivedsushi at yahoo.com
Wed Jun 27 16:25:14 EDT 2007
--- Stephen R Laniel <steve at laniels.org> wrote:
> On Mon, Jun 25, 2007 at 06:27:29PM -0700, Matthew Peter wrote:
> > For example, how do I get this to work?
> >
> > def func():
> > print "This is", __?__
> > return __caller__
> >
> > def echo():
> > print "This is ", __?__
> > return func()
>
> inspect is your friend:
> http://docs.python.org/lib/inspect-stack.html
>
> --
> Stephen R. Laniel
> steve at laniels.org
> Cell: +(617) 308-5571
> http://laniels.org/
> PGP key: http://laniels.org/slaniel.key
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--- Stephen R Laniel <steve at laniels.org> wrote:
> On Mon, Jun 25, 2007 at 06:27:29PM -0700, Matthew Peter wrote:
> > For example, how do I get this to work?
> >
> > def func():
> > print "This is", __?__
> > return __caller__
> >
> > def echo():
> > print "This is ", __?__
> > return func()
>
> inspect is your friend:
> http://docs.python.org/lib/inspect-stack.html
>
> --
> Stephen R. Laniel
> steve at laniels.org
> Cell: +(617) 308-5571
> http://laniels.org/
> PGP key: http://laniels.org/slaniel.key
> --
> http://mail.python.org/mailman/listinfo/python-list
>
Parsing the stack's tuple to get those attributes didn't feel reliable or pythonic.
I am likely overlooking something. Is there a brief example you could show me in the
context of using inspect to accomplish the goal I outlined above? The goal is using
a function and not a class. Thanks!
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC
More information about the Python-list
mailing list