Check with this code. It is tested on E71 with PyS60 1.9.6
The directory, file and the file contents are created as expected.
Code:
import codecs
import os, os.path
dir_path = u"C:\\Data\\MyApp"
file = "temp.ini"
newline = "\n"
def init_settings():
f = codecs.open(os.path.join(dir_path, file), 'w', 'utf_8')
settings = "variable_1" + newline
settings += "variable_2" + newline
settings += "variable_3" + newline
f.write(settings)
f.close()
def mk_dir():
if not os.path.exists(dir_path):
os.makedirs(dir_path)
mk_dir()
init_settings()