Sublime Forum

What change has been made to plugin's __file__ key?

#1

Hi,

Up until recently, (can’t say which exact 3.x build) I was using self made plugin and I used file variable to detect the path of running plugin script. For example:

class PythonCustomFunction(sublime_plugin.EventListener):

    def on_something(self, ...):
        root = os.path.dirname(__file__)

Now, I noticed that my plugin doesn’t work anymore, so I looked what might have been changed in the meantime, although plugin was made on 3.x series and was working as expected.

It turns out that now file variable returns:

C:\Program Files\Sublime Text 3\Packages\Python.sublime-package/Python.name_of_the_plugin

and accordingly os.path.dirname(file) returns more sane result as

C:\Program Files\Sublime Text 3\Packages\Python.sublime-package

Real plugin path is usual %APPDATA%\Sublime Text 3\Packages\Python

So I would like to know what was changed so that I can remedy possible problems in future, and what can I use now to return the path of actual working script?

TIA

0 Likes