pyDrivers inline import expression!

Hello, I have this script. It’s a silly one simply for test purposes.


import bpy

def test():
    print('test')
    return 100

Then I go to the Z Rotation of the object and create a single driver for it. Then I try to write an expression to import it on the fly. The problem is that I had done it in the past and I know that it works, but now I can’t find this file in my archives to study it and I can’t remember the exact way to do it.

Is it like this? (It does not work but it’s something similar to this)

__import__('Test').test()

P.S. I know about bpy.app.driver_namespace[‘test’] = test but I prefer inline imports better because they update right away and it’s useful for constructing and debugging stuff.

I create a script called Test.py (.py is important) and add this function there.

def test():
    return 'OK'

Now in the console window I try this and returns ‘OK’

__import__('Test').test()

Now if I change the test function to return ‘Foo’ the import declaration will not get the new value and will still remembers the old. Do you know how to correct this?