How to read the directory which the actively running python file is located in?
Gerold Penz
gerold.penz at tirol.utanet.at
Fri Dec 1 14:06:55 EST 2006
Michael Malinowski schrieb:
> Is there a way to read the directory that the currently running python file
> is located in?
Hi Mike!
To get the started program:
sys.argv[0]
Don´t use ``os.curdir``.
To get the filename, of the current module:
__file__
To get the directory:
os.path.split(sys.argv[0])[0]
os.path.split(__file__)[0]
Regards,
Gerold
:-)
--
________________________________________________________________________
Gerold Penz - bcom - Programmierung
gerold.penz at tirol.utanet.at | http://gerold.bcom.at | http://sw3.at
Ehrliche, herzliche Begeisterung ist einer der
wirksamsten Erfolgsfaktoren. Dale Carnegie
More information about the Python-list
mailing list