osx - How to find the directory of the .app that a python script is running from -


i made python script goes through files in whatever directory placed in , renames them based on criteria. script works perfectly, , compiled script os x .app using py2app. worked fine well. when run script, searches through files in ".app/contents/macos" folder (where script located) rather ".app" located.

this because has code @ start:

src = os.path.dirname(os.path.abspath(__file__)) 

which assigns the location of ".py" file variable used extensively throughout script. there way can instead add snippet of code tells python path location of ".app" ".py" file executing from?

if not, perhaps there way file explorer window open, there possible user select folder who's path assigned "src" variable. i'm new python challenge.

try use:

import os print(os.getcwd()) 

from docs:

getcwd()

return unicode string representing current working directory.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -