Commits

Jason R. Coombs committed 405444f

Invoke main loop as a for loop rather than a while with a break

Comments (0)

Files changed (1)

scripts/irccat.py

 #
 # Joel Rosdahl <joel@rosdahl.net>
 
+import sys
 import argparse
+import itertools
+
 import irc.client
-import sys
 
 target = None
 "The nick or channel to which to send messages"
 def on_join(connection, event):
     main_loop(connection)
 
+def get_lines():
+    while True:
+        yield sys.stdin.readline().strip()
+
 def main_loop(connection):
-    while True:
-        line = sys.stdin.readline().strip()
-        if not line:
-            break
+    for line in itertools.takewhile(bool, get_lines()):
+        print(line)
         connection.privmsg(target, line)
     connection.quit("Using irc.client.py")