problem reading a file in 2.5

we got a script from 2.49 reding a file like this


print ()

for line in open(filePath_).readlines():

print ('jj = ',jj,‘line=’,line)

but when doing this in 2.5 626 it does not recognise the file read and give error that it cannot find the file

looks like a change in default path may be !

anybody has an idea was this is not working in 2.5 ?

thanks for any help

Try that:
for line in open(bpy.path.abspath(filePath_)).readlines():

It works here (windoes 7). “//” is the directory where your blender file is.

thansk for your reply
interesting solution but not obvious at all!

is there any sort of doc page in wiki or else on this?

also i did find something here may be a bug

if i place the txt file in the folder where the blender.exe is located it works fine
and samething when i write it goes there not in the local folder where the blend file is located !
at least in version 315 626 but does not work like this in 2.49 !

is this a bug or normal ?


Go to Help Menu -> Python API Reference. It will point you to this page:

“same thing when I write it goes there (blender folder) not in the local folder where the blend file is located !”
Sorry, didn’t get it. What do you mean by write it?

it was doing something but did not know what
so i did a test by writting a simple tt file and found where it was

and i happen to be added to the folder where the blender.exe is lcoated instead of the lcoal fodler where the blend file is located

and it will also read from that folder - blender.exe is located

so ma be it the way it goes in 2.5 but nto like in 2,49



Thank you for this tips, but I have a py module located in the folder of the blend file.
This module is also not found. Before I added the abs path found in os.path with the append method, but it’s not the case now with 2.5? Is there a workarround?
Thank you for your help.