The path that you are referring to is dependent on the starting directory. You should use the __file__
global variable:
with open(os.path.join(
os.path.dirname(__file__), 'rooms', + str(id) + '.json'),
'r') as f:
jsontext = f.read()
I would also suggestion using os.path.join
to create the file name so that you can use the platform specific path separators.
Note that os.curdir()
will return the location from which the program was started, not the location of the rooms.py file.