#!/usr/bin/python import os, string def replace_var_with_cwd(file): X = open(file,'r').readlines() for i in range(len(X)): if X[i][0:len(var)] == var: splitted = X[i].split('=') splitted[1] = cwd+'\n' X[i] = string.join(splitted,'=') break open(file,'w').write(string.join(X,'')) var = 'PSYCHEPATH' cwd = os.getcwd() sphinxfile = cwd+'/sphinx/sphinx2-simple' rcfile = cwd+'/psycherc' for file in [sphinxfile, rcfile]: replace_var_with_cwd(file)