I'm writing a graphical application which will depend on a language file containing text snippets in different languages for the UI elements.
I want to store these files in a lang/ directory inside the package directory which is imported by the main application script when executed.
However, I can't use ./ when opening the language files for reading, because ./ is the working directory of the user, not the location of the imported Python file.
With a source structure that looks like
/
-- mypkg/
   -- lang/
      -- en_US.lang
      -- es_ES.lang
      -- <etc...>
   -- __init__.py
   -- lang.py
-- myapp (executable Python script which imports mypkg)
how can I reliably read from the lang/ directory without relying on a particular working directory?
 
    