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

Adam Hupp adam at hupp.org
Thu Dec 13 01:54:42 CET 2007

On Dec 12, 2007 4:10 PM, William Deegan <bdbaddog at gmail.com> wrote:
> 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?

If I understand the question correctly, I think you will have to pass
it in locals:

execfile("test.py", globals(), {"__file__": "test.py"})

Adam Hupp | http://hupp.org/adam/

More information about the Baypiggies mailing list