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


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

Re: Sort lines in a plain text file alphanumerically

Started byChris Angelico <rosuav@gmail.com>
First post2013-08-06 14:15 +0100
Last post2013-08-06 14:15 +0100
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: Sort lines in a plain text file alphanumerically Chris Angelico <rosuav@gmail.com> - 2013-08-06 14:15 +0100

#52038 — Re: Sort lines in a plain text file alphanumerically

FromChris Angelico <rosuav@gmail.com>
Date2013-08-06 14:15 +0100
SubjectRe: Sort lines in a plain text file alphanumerically
Message-ID<mailman.250.1375794915.1251.python-list@python.org>
On Tue, Aug 6, 2013 at 12:44 PM, Joshua Landau <joshua@landau.ws> wrote:
> On 6 August 2013 11:52, Chris Angelico <rosuav@gmail.com> wrote:
>> On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson
>> <devyncjohnson@gmail.com> wrote:
>>>     with open('/home/collier/pytest/sort.TXT') as file:
>>>         sorted(file, key=str.casefold, reverse=True)
>>>
>>>
>>> Thanks for the advice Joshua. I find these tips very useful. However, how
>>> would I close the files, or would they close after the "with" construct is
>>> complete?
>>
>>
>> That's the whole point of 'with'. It calls open(),
>
> To be pedantic, it does not. open is called by the time the with gets involved.
>

The entire statement does. Yes, it's not 'with' that does that, but it
is called. Anyway, that's detaily stuff :)

ChrisA

[toc] | [standalone]


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


csiph-web