[Python-Dev] Replacement for print in Python 3.0
Charles Cazabon
python at discworld.dyndns.org
Fri Sep 2 16:20:44 CEST 2005
Fredrik Lundh <fredrik at pythonware.com> wrote:
> >
> > print('foo:', foo, 'bar:', bar, 'baz:', baz,
> > 'frobble', frobble)
> >
> > To my (admittedly biased) eyes, the second version more obviously
> > prints to a single line.
>
> next use case:
>
> print 'foo:', foo, 'bar:', bar, 'baz:', baz,
> if frobble > 0:
> print 'frobble', frobble
> else:
> print 'no frobble today'
The need to print /and/ not add a newline isn't nearly as common. print()
could take a keyword parameter to skip the newline, or ...
print('foo:', foo, 'bar:', bar, 'baz:', baz,
frobble and 'frobble: ' + frobble or 'no frobble today')
Or the user can just use stdout.write and have full control.
Charles
--
-----------------------------------------------------------------------
Charles Cazabon <python at discworld.dyndns.org>
GPL'ed software available at: http://pyropus.ca/software/
-----------------------------------------------------------------------
More information about the Python-Dev
mailing list