Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70564 > unrolled thread

Re: how to write list in a file

Started byDave Angel <davea@davea.name>
First post2014-04-23 21:45 -0400
Last post2014-04-23 21:45 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: how to write list in a file Dave Angel <davea@davea.name> - 2014-04-23 21:45 -0400

#70564 — Re: how to write list in a file

FromDave Angel <davea@davea.name>
Date2014-04-23 21:45 -0400
SubjectRe: how to write list in a file
Message-ID<mailman.9478.1398303588.18130.python-list@python.org>
Terry Reedy <tjreedy@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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web