#always use absolute paths import os def write_pid(): pid = os.getpid() with open('/tmp/battleship_server.pid', 'w') as f: f.write(str(pid)) print('Hello my(i \'m battleship server) pid is ' + str(pid))