Find directory name of file?

ngw nicholas_wieland at noyahoospam.it
Mon Jan 30 06:46:23 EST 2006


-veracon <veracon at gmail.com>:
> I'm pretty new at Python, so I have no idea how to do this: How do I
> find the name of the directory that contains the application currently
> being executed (e.g. if the file is /home/user/file.py, I want to get
> the /home/user part)?

Try os.path.dirname (__file__)

HTH,
  ngw



More information about the Python-list mailing list