sys.argv[0] doesn't always contain the full path of running script.

John Machin sjmachin at lexicon.net
Thu Aug 31 17:12:43 EDT 2006


Ivan Zuzak wrote:
> Joel Hedlund wrote:
>
> > Yes indeed! But the path to the module will not be the same as the path to
> > the script if you are currently in an imported module. Consider this:
>
> I thought that was the point - to get the full path of the running
> script? I see you use the terms "script" and "module" in different
> contexts, while I use them as: script = module = file. I can't say
> which is right, though :).
>

If you execute fubar.py, it's a script with  __name__ == "__main__"; if
you import it, it's a module __name__ == "fubar".




More information about the Python-list mailing list