From: Colin Watson Date: Thu, 14 Jun 2012 02:00:33 +0000 (+0100) Subject: tiocnotty: use with statement X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=241d32c3a03c0004ff163d3cacdcbcc6cf7820d2;p=bin.git tiocnotty: use with statement --- diff --git a/tiocnotty b/tiocnotty index 694c62d..1324d3a 100755 --- a/tiocnotty +++ b/tiocnotty @@ -6,9 +6,8 @@ import sys import termios try: - tty = open('/dev/tty') - fcntl.ioctl(tty, termios.TIOCNOTTY) - tty.close() + with open('/dev/tty') as tty: + fcntl.ioctl(tty, termios.TIOCNOTTY) except IOError: pass