bob gailer wrote:

Elisha Rosensweig wrote:
> Hi,
>
> How can I determine the directory in which a module is located, from > within that module?
sys.modules[__name__].__file__
-- Bob Gailer
Or more simply,
   __file__

But the OP wanted the directory, which can be extracted with method dirname:

import os
print __file__
print os.path.dirname(__file__)


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to