[Tutor] How to change default path output of 'logging'?

Juan Christian juan0christian at gmail.com
Mon Dec 22 17:41:09 CET 2014


On Mon Dec 22 2014 at 1:35:44 PM Dave Angel <davea at davea.name> wrote:
>
> No idea what part main.py plays to your code.  If it's imported, then
> you could use main.__file__  to get the full pathname to it.  Then use
> os.path.dirname() to get the directory.  Then use os.path.join() to
> combine that with "bumpr.log".
>
> More likely, this is your script.  So if you're trying to get the
> filename from the script, you just use
>    __file__
>
> And if that doesn't show up as an absolute path, use os.path.abspath.  i
> couldn't test that part, since I don't use Windows, and can't play with
> the Windows Task Scheduler.
>

Thanks guys, it worked like a charm.

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.


More information about the Tutor mailing list