[Tutor] What is the best way for a program suite to know where it is installed?

eryk sun eryksun at gmail.com
Mon Oct 22 23:06:50 EDT 2018

On 10/22/18, boB Stepp <robertvstepp at gmail.com> wrote:
> Importing the various program modules/module contents is
> no issue.  Where I believe I need to know the paths to things are to
> get to data folders, config files, and occasionally utility programs
> that I have written that are on my hard drive, but not copied to my
> current program suite.

It's common to use __file__ for a portable application, except you
should use sys.executable if it's a frozen executable, i.e. if
sys.frozen exists.

For an installed application, limit this approach to the application's
immutable resources. Don't use the installation directory to store
modifiable data. You may not have write access (e.g. a system
installation and the user lacks root/admin access, or it's an
immutable directory or read-only disk mount).

More information about the Tutor mailing list