Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #70564 > unrolled thread
| Started by | Dave Angel <davea@davea.name> |
|---|---|
| First post | 2014-04-23 21:45 -0400 |
| Last post | 2014-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.
Re: how to write list in a file Dave Angel <davea@davea.name> - 2014-04-23 21:45 -0400
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2014-04-23 21:45 -0400 |
| Subject | Re: 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
Back to top | Article view | comp.lang.python
csiph-web