VMM/cli: small optimizations in the functions w_std() and w_err() v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Sat, 27 Feb 2010 06:24:20 +0000
branchv0.6.x
changeset 217 eecd05e31517
parent 216 0c8c053b451c
child 218 84094c7fa28b
VMM/cli: small optimizations in the functions w_std() and w_err()
VirtualMailManager/cli/__init__.py
--- a/VirtualMailManager/cli/__init__.py	Fri Feb 26 02:35:25 2010 +0000
+++ b/VirtualMailManager/cli/__init__.py	Sat Feb 27 06:24:20 2010 +0000
@@ -23,22 +23,24 @@
 
 
 def w_std(*args):
-    """Writes each arg of `args`, encoded in the current ENCODING, to stdout
-    and appends a newline."""
-    for arg in args:
-        _std_write(arg.encode(ENCODING, 'replace'))
-        _std_write('\n')
+    """Writes a line for each arg of *args*, encoded in the current
+    ENCODING, to stdout.
+
+    """
+    _std_write('\n'.join(arg.encode(ENCODING, 'replace') for arg in args))
+    _std_write('\n')
 
 
 def w_err(code, *args):
-    """Writes each arg of `args`, encoded in the current ENCODING, to stderr
-    and appends a newline.
+    """Writes a line for each arg of *args*, encoded in the current
+    ENCODING, to stderr.
 
     This function additional interrupts the program execution and uses
-    `code` system exit status."""
-    for arg in args:
-        _err_write(arg.encode(ENCODING, 'replace'))
-        _err_write('\n')
+    *code* as the system exit status.
+
+    """
+    _err_write('\n'.join(arg.encode(ENCODING, 'replace') for arg in args))
+    _err_write('\n')
     os.sys.exit(code)