Terry Reedy <tjre...@udel.edu> Wrote in message: > On 4/23/2014 3:53 AM, Dhananjay wrote: >> Hello everyone, >> >> I am trying hard to write a list to a file as follows: >> >> >> def average_ELECT(pwd): >> os.chdir(pwd) > > I would 'print pwd' to make sure where files are being opened. > >> files = filter(os.path.isfile, os.listdir('./')) >>
I wouldn't. I've seen too many flaky problems to trust os.chdir in real code. I think the op should build each filename with os.path.append or similar. All paths used for actual file operations should either be absolute, or strictly relative to the user's cwd when the script started. And even the latter is suspect when you're anywhere near Windows. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list