[Baypiggies] Can you get the filename which is being execfile()'d from within the file being execfiled?

Douglas Sims doug at apley.com
Thu Dec 13 02:03:10 CET 2007


Interesting question.

I think you can get that with:


sys._getframe().f_code.co_filename


Douglas Sims
Doug at Apley.com



On Dec 12, 2007, at 6:10 PM, William Deegan wrote:

> Greetings,
>
>
> If I execfile('abc.py')
>
> And abc.py calls function tellme().
> Is there a global or a way to pass to tellme() the filename being  
> execfile()'d?
>
> Let me know if this is not clear.
>
> Thanks,
> Bill
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies



More information about the Baypiggies mailing list