chiark / gitweb /
tiocnotty: use with statement
[bin.git] / tiocnotty
index 1bf635e7e9d0dde24f8bfe7f4925a5cfb401f4b0..1324d3a90bb479fc6c417832cd5e91eee710f454 100755 (executable)
--- a/tiocnotty
+++ b/tiocnotty
@@ -1,14 +1,13 @@
 #! /usr/bin/python
 
-import sys
-import os
 import fcntl
+import os
+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