I want to develop a ST3 plugin that requires a larger amount of logic. In order to keep the code readable, I want to split the logic and ST-related party into different files (Python modules).
If I create a new directory for my Sublime Text plugin, containing two files, plugin.py and othermod.py (empty), and insert the following content into plugin.py
import sublime, sublime_plugin
import othermod
#my plugin code here
the Sublime console outputs
ImportError: No module named 'othermod'
and the plugin.py file is skipped.
Is there any way to import othermod from within my plugin.py?
You need a file called __init__.py
in the same directory as your other files. Exactly why you need __init__.py
is explained here. Also, just to be on the safe side, make sure that you've actually saved both of the files. Sometimes you need to restart Sublime before it'll recognize your file as a module.