"print" as function not statement

John Roth newsgroups at jhrothjr.com
Mon Mar 8 03:38:01 CET 2004


"Paul Prescod" <paul at prescod.net> wrote in message
news:mailman.107.1078707454.19534.python-list at python.org...
> This is just a trial balloon. It isn't even in proper PEP format yet.
> Don't take it too personally!

Why would I take it personally? [grin]

It's an interesting proposal. As far as I'm concerned, the
print statement has two uses:

1. It's a handy way of getting output for debugging, and
2. It's a handy way of producing output for quick,
 one-off scripts.

Also AFAIAC, it has no utility in larger programs; the
<file>.write() method is more than adequate and
provides much better control for normal output;
debug output is better served by the logging module.

The only purpose I can see for a functional form
of the print statement is in your extension suggestion:
a function that would return its (single) parameter
while at the same time printing it out. This could be
quite useful in debugging if you want to provide a
very precise probe without having to rewrite a
statement to get a print in the appropriate place.

I'd suggest putting together a module with your
proposed show() function and publicizing it.

Print is definitely quirky, and I wouldn't be sorry
to see it go.

John Roth






More information about the Python-list mailing list