How to call a method from a different blender text than the current one

I am coding a blender project and the code I am writing is just too much to be contained in one blender text script. I have looked at Blender.Run(script) it is a nice way to organize the script in different pieces. Unfortunately this is not what I am looking for.

My question is: Assume that I have two scripts in blender text window(2 files called X and Y) is it possible to call a method that exist in script Y from script X.

for example: script Y has a method called printThis(), and script X wants to call that method is there a way to have it called from script X as in Y.printThis() ???


Unless I’m missing something, just import the other script. Include one of these lines in scriptx

import scripty


from scripty import *

In the first case, reference the method with scripty.printThis()
In the second, just printThis()

I think that if you want to call procs from a text file called “scripty” in the same .blend file, you should rename it to “” and only then you can use:

from scripty import *


On the other hand, if you want to include the file ~/foo/, but you don’t want to open it in Blender’s text editor (e.g. because you have a big project with 200 files), you could try this:

import bpy, sys, os

path = os.path.expanduser('~/foo')
import bar

Beware however that Blender will not update if you change it in an external editor.

Thanks guys for the reply. It helped a lot.