import value from external modul

hi

i have problem with importing python modul and follow-up reading value from list.

i have file with name “memory” which include:

value = [0,1,0]

when i was wrote in Blender

from memory import value

blender shown me that …

no modul name memory

I have in Blender defined way to Python script to the same folder where is’t modul named “memory.py”

so why don’t blender is not able find this modul

thanks jm

I believe this is because memory.py is not a module but a script. In order for something to be a module, it has to have functions and/or classes to import. You can not import objects from a script, you can only import classes and functions. What you could do is this:

in memory.py:


def value():
   return [0,1,0]


in game:
from memory import value
v = value()  #v now equals [0,1,0]

I’m not entirely sure this is the problem, but it’s worth a shot. If this still doesn’t work, blender is trying to import the .py from a different directory, most likely the directory where the blenderpublisher.exe is. try moving the file there and see if it works.

thanks a lot :smiley:

…sorry I still have problem, so a post it.
I need imput values to a external script or file as long as their number will be 10.
i.e.

value[0,1,0,0,0]

etc.
if their number will 10, then I need delete first of them.
i try post index to the external file and open it for read and write and deletion, but as I post my problem before it is not able to open file with using
from memory import value …with file increase only index
value = [0,1,0]

at this time with yor help I still don’t be able append other number and after delete first.

when I use

v.append[0]

it only rewrite last number of value.

thanks a lot of your help.

jm