[Zope-Coders] Re: [Zope-Checkins] CVS: Zope/lib/python/DateTime/tests -testDateTime.py:1.12.6.3

Guido van Rossum guido@python.org
Thu, 17 Oct 2002 11:26:51 -0400


> Isn't __file__ only defined when a module is imported but
> undefined when the file is run directly from the Python
> interpreter.

Correct.  In that case, sys.argv[0] will usually work, though that's
up to the shell, and there are cases where you won't be able to
recover the true directory (e.g. when the shell's PATH is different
from what is exported into os.environ).

--Guido van Rossum (home page: http://www.python.org/~guido/)