Browse Source

use "with" to handle files

master
Ben Savage 7 years ago
parent
commit
d3b8668801
  1. 5
      stanza

5
stanza

@ -36,10 +36,7 @@ def debug(line):
debug(pformat(args)) debug(pformat(args))
# Set up the file handle, <file> or stdin # Set up the file handle, <file> or stdin
if cmd.filename: with open(cmd.filename,'r') if cmd.filename else sys.stdin as handle:
handle=open(cmd.filename)
else:
handle=sys.stdin
# Go over the handle, line by line # Go over the handle, line by line
for line in handle: for line in handle:
# Start buffering if we hit the start regex # Start buffering if we hit the start regex

Loading…
Cancel
Save