From 5fcd7d8d500989ff6fa49cc998ba71c579e41fe4 Mon Sep 17 00:00:00 2001 From: bwarsaw Date: Mon, 24 Jul 2000 06:08:12 +0000 Subject: write(): Function that acts like print, but let's you specify the output file, whether a trailing newline should be printed, and the separator string. (Sidenote: this is partly to play with some suggestions currently being floated on the python-dev mailing list). --- Mailman/Utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 8188cf15b..1c111b63b 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -632,3 +632,23 @@ def unhexlify(s): for i in range(0, len(s), 2): append(chr(int16(s[i:i+2], 16))) return string.join(acc, '') + + + +def write(*args, **kws): + file = sys.stdout + sep = ' ' + end = '\n' + if kws.has_key('file'): + file = kws['file'] + del kws['file'] + if kws.has_key('nl'): + if not kws['nl']: + end = ' ' + del kws['nl'] + if kws.has_key('sep'): + sep = kws['sep'] + del kws['sep'] + if kws: + raise TypeError('unexpected keywords') + file.write(sep.join(map(str, args)) + end) -- cgit v1.3.1