[Python-3000] print() parameters in py3k

Guido van Rossum guido at python.org
Sun Nov 19 22:55:04 CET 2006


On 11/19/06, Georg Brandl <g.brandl at gmx.net> wrote:
> Guido van Rossum wrote:
> > On 11/19/06, James Thiele <python3now at gmail.com> wrote:
> >> The BDFL has said that print will change from a statement to a function in
> >> Python 3.
> >>
> >> I haven't found anything describing what parameters it will take and what it
> >> will return. Has this been decided?
> >
> > Not really, I'm hoping someone would write a PEP. But (from memory, I
> > think there are some threads on python-dev or the py3k list about
> > this) here are some suggestions:
> >
> > 1. With only positional parameters (or none at all), print(x, y, z) is
> > equivalent to "print x, y, z" today. So it converts each argument
> > using str(), inserting spaces in between, and appending a newline.
> >
> > 2. A keyword parameter will direct it to a different file.
> > Probably print(x, y, z, file=<file-like object>).
> >
> > 3. Two more keyword parameters can change what gets inserted between
> > items and at the end.
> > Perhaps print(x, y, z, sep=<string>, end=<string>). These default to "
> > " and "\n", respectively.
> >
> > 4. The softspace feature (a semi-secret attribute on files currently
> > used to tell print whether to insert a space before the first item)
> > will be killed.
>
> Do we even need a PEP? This is a good, easy-to-explain interface. Is more
> functionality needed?

PEPs aren't only for difficult discussions. :-) They are also there
for reference and to record agreement. Referring to an email isn't
really a very good answer when someone asks (as happened here) "what
is the spec"?  A PEP may also discourage attempts to add more cruft,
and encourage someone with a few spare cycles to provide a patch so we
can put the whole thing behind it.

BTW I forgot to mention that it shouldn't return anything.

(So are you going to write that PEP? :-)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list