On 12/22/2014 11:41 AM, Juan Christian wrote:
str(os.path.abspath(__file__)).replace('main.py', '')
So I get the full-path of my main dir where main.py is and all the other
modules/packages too, no matter if I'm on OSX/Win/Linux.
That's not the best way to get the directory path for a file. You
should use os.path.dirname(). That way if the basename changes from
main.py to something else (like main.pyc, or main.pyw, or
usefulcode.py), it'll still work. It fixes other problems also, that
are less likely to occur.
os.path.dirname(os.path.abspath(__file__)) should do it for you. And
that means that you want something like:
filename=os.path.join(os.path.dirname(os.path.abspath(__file__)),
"bumpr.log")
(untested)
--
DaveA
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor