filename of calling function?

Phlip phlip2005 at gmail.com
Sat Nov 28 12:37:13 EST 2009


On Nov 28, 9:04 am, Joel Davis <callmeclaud... at gmail.com> wrote:

> >         try:
> >             raise None
> >         except:
> >             import sys
> >             from traceback import extract_tb, extract_stack
> >             frame = sys.exc_info()[2].tb_frame.f_back
> >             calling_file = extract_stack(frame, 2)[1][0]
>
> code works perfectly except on my system both the indexes need to be 0
> (eg: "extract_stack(frame, 2)[0][0]")

I thought the 0 was myself, 1 my caller, etc. But tx for trying it



More information about the Python-list mailing list