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

Niall O'Higgins niallo at unworkable.org
Thu Dec 13 01:22:45 CET 2007

If I've understood you correctly, sys.argv[0] may be what you are
looking for?


$ cat blah.py
import sys

print sys.argv[0]
$ python blah.py

On Wed, Dec 12, 2007 at 04:10:24PM -0800, 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