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

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -