[Python-Dev] extended print statement, uPre-PEP
Peter Schneider-Kamp
peter@schneider-kamp.de
Sun, 23 Jul 2000 08:21:33 +0000
First I want to say, that I use the print statement mainly
for debugging and for "print func.__doc__" in the shell,
but I would be very unhappy to see it go away.
quasi patch for readline:
Moshe Zadka wrote:
>
> Reference implementation:
>
> def writeln(*args, **kw):
> import sys
> file = sys.stdout
> end = '\n'
+ joinstring = ' '
> if kw.has_key("file"):
> file = kw['file']
> del kw['file']
+ if kw.has_key("join"):
+ joinstring = kw['join']
+ del kw['join']
> if kw.has_key("nl"):
> if not kw['nl']:
! end = joinstring
> del kw['nl']
! file.write(joinstring.join(map(str, args))+end)
Or this one <wink>:
def writeln(*args, **kw):
import sys
file = sys.stdout
end = ''
if kw.has_key("file"):
sys.stdout = kw['file']
del kw['file']
if kw.has_key("nl"):
if not kw['nl']:
end = ','
del kw['nl']
exec("print "+", ".join(map(repr,args))+end)
having-slept-for-three-hours-ly y'rs
Peter
--
Peter Schneider-Kamp ++47-7388-7331
Herman Krags veg 51-11 mailto:peter@schneider-kamp.de
N-7050 Trondheim http://schneider-kamp.de