On Nov 28, 8:19 am, Phlip <phlip2...@gmail.com> wrote:
> Consider these two python modules:
>
> aa.py
>
> def a():
>     print '?'
>
> bb.py
>   import aa
>
> def bb():
>   aa.a()
>
> bb()
>
> How do I make the print line emit the filename of bb.py? (It could be
> anything.)

        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]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to