[Python-3000] print() parameters in py3k

Guido van Rossum guido at python.org
Tue Nov 21 02:38:20 CET 2006


[Sorry, sent before its time]

On 11/20/06, Guido van Rossum <guido at python.org> wrote:
> On 11/20/06, Barry Warsaw <barry at python.org> wrote:
> > On Nov 20, 2006, at 2:52 PM, Guido van Rossum wrote:
> > > I still don't quite see how making print a callable object solves that
> > > issue.
> >
> > It solves it by making the stream an attribute on the callable
> > instead of an argument to the call.
>
I'm still confused. Are you proposing that in order to print to a
different file we do

save_file = print.file
try:
  print.file = open("log.txt", "a")
  print(x, y, z)
finally:
  print.file = save_file

etc.?
>
> > > But personally would be totally happy with "You can't use
> > > 'file' as a variable name in your format". ('end' and 'sep' should not
> > > be supported by printf(), these should just be made part of the format
> > > string.)
> >
> > If 'file' is the only special keyword argument to printf, then let's
> > call it '_file' or some such.  There's probably less chance that a
> > newbie will want to change the output stream than they'll want to use
> > a file variable in their format string.

-0. I really don't want it to be _file for the basic print(); and
making them different is asking for trouble.

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


More information about the Python-3000 mailing list