python, function and local folder

Hi all:

I’m writing a script in python for blender and I want to define a function (I’m new to python). I create the function and put the file in the same folder as the blend file. In the main script I write

import function #(which remember, is in the same folder)

but blender keeps saying ImportError: No module named

How can I tell Blender to look for the module in the same folder that holds the blend file?

Thanks in advance!

I don’t understand excatly what you are trying to achieve.

If you are talking about importing a python module :

The module you want to import must be on the python path.
By default, at the start, Blender look in several locations (i.e. : the addons folder) and add them to the python path.

In the python console, to see what’s currently in the python path :

import sys

If the module you want to import is in one of them [folders], your module can be imported.

If you are talking about a function:

def my_function():
    # do stuffs

# and later in the same .py file
my_function() #works, do stuffs

Hope that helps

well, everything helps because I have just started learning python! :slight_smile: so thanks. But I have just discovered that my problem had to do with reloading modules (something new for! I come from fortran)

Thanks anyway!