[Python-Dev] Replacement for print in Python 3.0

Martin Blais martin.blais at gmail.com
Sat Sep 3 01:07:16 CEST 2005


On 9/2/05, Charles Cazabon <python at discworld.dyndns.org> wrote:
> 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')

Ouf, I'm just feeling an evil idea creeping up just now:

   print('foo:', foo, 'bar:', bar, 'baz:', baz,)

Just kidding, really...

Funny enough, the syntax does not barf and goes undetected:

>>> def foo( a, b, c ):
...     print a, b, c
... 
>>> foo(1, 2, 3,)
1 2 3
>>>


More information about the Python-Dev mailing list