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)
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 be pretty obnoxious.
I tried Joshua's suggestion in Python3.3 and it worked. What version of
Python are you using?
DCJ
--
http://mail.python.org/mailman/listinfo/python-list