[Python-Dev] extended print statement, uPre-PEP
Barry A. Warsaw
bwarsaw@beopen.com
Sun, 23 Jul 2000 23:01:42 -0400 (EDT)
>>>>> "MZ" == Moshe Zadka <moshez@math.huji.ac.il> writes:
MZ> But I'm -0 on that, preferring a new sys function, called
MZ> writeln
MZ> That would be extremely readable, require no new syntax and no
MZ> additional builtins.
MZ> Reference implementation:
Add a `sep' keyword, check for residual keyword arguments, and I might
be +0 on that. Of course, now you're in the realm of...
so-easy-i'll-just-cut-and-paste-this-into-my-own-app-ly y'rs,
-Barry
-------------------- snip snip --------------------
def writeln(*args, **kws):
import sys
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)