Small optimization in w_std()/w_err() 'avoid the dot'.
authorPascal Volk <neverseen@users.sourceforge.net>
Fri, 04 Sep 2009 19:38:50 +0000
changeset 141 ecd6a379e523
parent 140 ffac064bd728
child 142 28f26f7f3d8f
Small optimization in w_std()/w_err() 'avoid the dot'.
VirtualMailManager/__init__.py
--- a/VirtualMailManager/__init__.py	Thu Sep 03 05:33:52 2009 +0000
+++ b/VirtualMailManager/__init__.py	Fri Sep 04 19:38:50 2009 +0000
@@ -19,18 +19,20 @@
 def w_std(*args):
     """Writes each arg of args, encoded in the current ENCODING, to stdout and
     appends a newline."""
+    _write = os.sys.stdout.write
     for arg in args:
-        os.sys.stdout.write(arg.encode(ENCODING, 'replace'))
-        os.sys.stdout.write('\n')
+        _write(arg.encode(ENCODING, 'replace'))
+        _write('\n')
 
 def w_err(code, *args):
     """Writes each arg of args, encoded in the current ENCODING, to stderr and
     appends a newline.
     This function additional interrupts the program execution and uses 'code'
     system exit status."""
+    _write = os.sys.stderr.write
     for arg in args:
-        os.sys.stderr.write(arg.encode(ENCODING, 'replace'))
-        os.sys.stderr.write('\n')
+        _write(arg.encode(ENCODING, 'replace'))
+        _write('\n')
     os.sys.exit(code)
 
 __all__ = [