
6 Jul
2016
6 Jul
'16
2:16 a.m.
On Wed, 6 Jul 2016 01:20:04 +0000, Ian Stewart wrote:
f = open(filename, "r")
...
f.close()
No need to worry about closing a file that was opened read-only. Also, true command-line tools read their args from the command line, not from additional user input. :) The One True Way to write this is as a filter that reads from stdin and writes to stdout. Viz: #!/usr/bin/python3 import sys sys.stdout.write \ ( "".join(reversed(list(sys.stdin))) ) VoilĂ . :)