On 08/05/2013 10:19 PM, MRAB wrote:
On 06/08/2013 03:00, Devyn Collier Johnson wrote:
I am wanting to sort a plain text file alphanumerically by the lines. I
have tried this code, but I get an error. I assume this command does not
accept newline characters.
file = open('/home/collier
On 08/05/2013 10:19 PM, MRAB wrote:
On 06/08/2013 03:00, Devyn Collier Johnson wrote:
I am wanting to sort a plain text file alphanumerically by the lines. I
have tried this code, but I get an error. I assume this command does not
accept newline characters.
file = open('/home/collier
On 08/05/2013 11:49 PM, alex23 wrote:
On 6/08/2013 1:12 PM, Joshua Landau wrote:
Because it's bad to open files without a with unless you know what
you're doing, use a with:
with open('/home/collier/pytest/__sort.TXT') as file:
sorted(file, key=str.casefold, reverse=True)
On 08/05/2013 11:12 PM, Joshua Landau wrote:
On 6 August 2013 03:00, Devyn Collier Johnson devyncjohn...@gmail.com
mailto:devyncjohn...@gmail.com wrote:
I am wanting to sort a plain text file alphanumerically by the
lines. I have tried this code, but I get an error. I assume
On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson
devyncjohn...@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
On 6 August 2013 11:52, Chris Angelico ros...@gmail.com wrote:
On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson
devyncjohn...@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
On 08/06/2013 06:52 AM, Chris Angelico wrote:
On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson
devyncjohn...@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
On Tue, Aug 6, 2013 at 12:44 PM, Joshua Landau jos...@landau.ws wrote:
On 6 August 2013 11:52, Chris Angelico ros...@gmail.com wrote:
On Tue, Aug 6, 2013 at 11:38 AM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:
with open('/home/collier/pytest/sort.TXT') as file:
I am wanting to sort a plain text file alphanumerically by the lines. I
have tried this code, but I get an error. I assume this command does not
accept newline characters.
file = open('/home/collier/pytest/sort.TXT', 'r').read()
print(file)
z
c
w
r
h
s
d
file.sort() #The first blank line
On 06/08/2013 03:00, Devyn Collier Johnson wrote:
I am wanting to sort a plain text file alphanumerically by the lines. I
have tried this code, but I get an error. I assume this command does not
accept newline characters.
file = open('/home/collier/pytest/sort.TXT', 'r').read
On 6 August 2013 03:00, Devyn Collier Johnson devyncjohn...@gmail.comwrote:
I am wanting to sort a plain text file alphanumerically by the lines. I
have tried this code, but I get an error. I assume this command does not
accept newline characters.
HINT #1: Don't assume that without a reason
On Monday, August 5, 2013 10:00:55 PM UTC-4, Devyn Collier Johnson wrote:
I am wanting to sort a plain text file alphanumerically by the lines. I
have tried this code, but I get an error. I assume this command does not
accept newline characters.
file = open('/home/collier
On 6/08/2013 1:12 PM, Joshua Landau wrote:
Because it's bad to open files without a with unless you know what
you're doing, use a with:
with open('/home/collier/pytest/__sort.TXT') as file:
sorted(file, key=str.casefold, reverse=True)
Shouldn't that be:
with
On 6/08/2013 1:49 PM, alex23 wrote:
Shouldn't that be:
with open('/home/collier/pytest/__sort.TXT') as file:
data = file.readlines()
sorted(data, key=str.casefold, reverse=True)
I'm tempted to say HINT #5: don't provide a solution without testing it
first but that would
On 6/08/2013 1:49 PM, alex23 wrote:
On 6/08/2013 1:12 PM, Joshua Landau wrote:
Because it's bad to open files without a with unless you know what
you're doing, use a with:
with open('/home/collier/pytest/__sort.TXT') as file:
sorted(file, key=str.casefold, reverse=True)
15 matches
Mail list logo