Re: suppressing output, and a command-line flag to support it

Tim Peters (tim@ksr.com)
Sat, 02 Apr 94 21:41:30 EST

Tommy, you (& Jim) convinced me that Python's printing default is a
genuine pain in the butt for you, & that what you want to do is
reasonable.

Now you only need to convince Guido. Curiously enough, _before_ you
convinced me, you were in exactly the same boat <wink>!

The problem with a command-line switch is that we end up with two flavors
of Python, one that prints expressions and another that doesn't. If
never the twain shall meet, that's fine. But they will meet, and I'll
have the delightful choice of being deluged with senseless output from
your modules, or not seeing the output from somebody else's package.

OTOH, Guido's not likely to buy into a new statement for this, and (just
guessing <snort>) you're not likely buy into using it even if he would.

Is there any way out of this?! For a while I thought that since _I_
never use the expression-print feature except in interactive mode,
perhaps it would be reasonable to change Python to suppress printing
outside of interactive mode (after all, if _I_ wouldn't mind that, who
possibly could <wink>?). But then I'm deluged with senseless output the
first time I try one of your modules interactively.

If you were me, you would have saved the world these headaches by doing

void = obj.method().method().method()...

from the start (this is not the first time I've noted how many problems
are caused by other people not being me!).

One kludge I considered I won't even mention: every language allows
using unary '+', yet no line of code has ever been written that uses it.
So there would be no harm in saying that if an expression-line begins
with a "+", the value won't be printed. Then nothing real would break,
you could write

+ obj.method().method().method()...

(which has the added advantage of looking way cool!), all Pythons would
act the same, and Guido wouldn't have to decline to introduce a new
statement. Would you be willing to do that? Would he?

I refused to mention that idea because it would have been embarrassing to
admit it's the best compromise I've been able to think of.

> When I stated in an earlier post that there was a flag that I
> thought would do this that didn't I was talking about the '-k' flag.
> It just seemed odd to me that if you wanted to produce a program that
> gave no output, raising an exception when an expression might have
> printed was implemented before simply not printing the expression
> values!

As I recall, the thrust of -k wasn't for people who merely didn't want
output (they could redirect to /dev/null for that <0.9 grin>), but for
people plagued by unexpected mystery output. -k helped find the cause.
It was a different agenda.

> [steve]
> [ Class Object() is an Ultra, Ultra Secret project that,
> other than myself, only Tommy knows about!
> But I suspect that Tim can guess...
> We'll just have to have him shot! ;-) ]

No, really, I'd be delighted to shoot myself if it would save you the
bother <smile>.

hoping-you-realize-that-*all*-dutch-language-designers-dislike-
smalltalk-ly y'rs - tim

Tim Peters tim@ksr.com
not speaking for Kendall Square Research Corp