[Python-3000] print() parameters in py3k

Guido van Rossum guido at python.org
Tue Nov 21 02:36:53 CET 2006


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)

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.
>
> - -Barry
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (Darwin)
>
> iQCVAwUBRWIMi3EjvBPtnXfVAQJ2aQP/Qcq+J5ZN0p6aH0QJSO5W7HpJ/MpBQCWu
> vRQTu13NHFscPNIC3SFvRIg/QPZdpMYSpEUZSl4BUuQMp+MEGSSKKFbq14DyDTfV
> O7VZ8QjN94EL410cZAHS2PZSZzGo0eG96zwSiGkEK+pjuKVwML+nTSq0xQqJF8Yu
> w7btiFT/ThY=
> =SxCt
> -----END PGP SIGNATURE-----
>


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


More information about the Python-3000 mailing list