[Python-Dev] extended print statement, uPre-PEP
Moshe Zadka
Moshe Zadka <moshez@math.huji.ac.il>
Sun, 23 Jul 2000 08:09:15 +0300 (IDT)
On Sat, 22 Jul 2000, Paul Prescod wrote:
> "Barry A. Warsaw" wrote:
> >
> > ...
> > Because it's less readable.
> >
> > log.write('post to %s from %s, size=%d\n' % (listname, sender, len(msg)))
> >
> > vs
> >
> > print 'post to', listname, 'from', sender, 'size=', len(msg)
>
> Okay, how about
>
> log.writeln("Post to ", listname, " from ", sender, " size=", len( msg
> ))
Better yet, have writeln auto put spaces, and you have
log.writeln("Post to", listname, "from", sender, "size=%s" % len(msg))
But I'm -0 on that, preferring a new sys function, called writeln
writeln("......")
writeln(file=logfile, "fffffff", "ffff")
and of course
writeln(nl=0, "ffffff")
to simulate
print "ffffff",
That would be extremely readable, require no new syntax and no additional
builtins.
Reference implementation:
def writeln(*args, **kw):
import sys
file = sys.stdout
end = '\n'
if kw.has_key("file"):
file = kw['file']
del kw['file']
if kw.has_key("nl"):
if not kw['nl']:
end = ' '
del kw['nl']
file.write(" ".join(map(str, args))+end)
--
Moshe Zadka <moshez@math.huji.ac.il>
There is no GOD but Python, and HTTP is its prophet.
http://advogato.org/person/moshez