Saving pickle's output to the folder where .blend file is?

my script looks something like this:

import Blender
import pickle

SomeJunk = "blah blah blah"

f = file('junk.txt', 'w')
pickle.dump(SomeJunk, f)
f.close()

The output always goes to Blender’s folder, as in the one with Blender.exe. Is there a way to save the output to the folder containing the .blend file the script was run from? thanks!


import Blender
ls=Blender.Get(‘filename’)
rep=Blender.sys.dirname(ls)


… well anway

import Blender 
import pickle 

SomeJunk = "blah blah blah" 

f = file(Blender.sys.dirname(Blender.Get('filename')) + Blender.sys.sep + 'junk.txt', 'w') 
pickle.dump(SomeJunk, f) 
f.close()

before now I didn’t know that the often-used parts of the os module were in Blender.sys

Perfect, problem solved! Thanks guys! :smiley: