[Python-Dev] extended print statement, uPre-PEP

Paul Prescod paul@prescod.net
Sun, 23 Jul 2000 10:31:03 -0500

Fredrik Lundh wrote:
> paul wrote:
> > Nevertheless, every Python programmer needs to learn the ".write" way in
> > order to do reasonable text processing. So print's idiosyncracies are
> > just one more thing to learn.
> ...and since people need to learn how to write classes to write
> larger programs, we can disallow statements and functions on the
> module level...

My first reaction was: "Great, you've demonstrated that any argument can
be extended and parodied into meaningless. Big deal."

But on second thought, you haven't even done that. Everything you learn
about statements and functions is directly useful when you learn
classes. It builds naturally. There is no conflict.

Print is a magical syntax zone where everything works differently:

 * "," means concatenate, 
 * objects are automatically coerced to strings, 
 * newlines appear out of nowhere
 * parentheses change the behavior radically
 * (soon maybe) ">>" is used to redirect object invocations

Nothing you learn there will help you to learn stderr.write(...) which
works completely differently.

> >>> usability_guidelines.index("they have to learn it anyway")
> Traceback (most recent call last):
> ValueError: list.index(x): x not in list

Oh really? I thought that this was in the guidelines:

"There should be one-- and preferably only one --obvious way to do it.."

Of course it must be balanced with everything else in the guidelines,
but it should be a factor. Also:

"Special cases aren't special enough to break the rules."

What could be more special than a unique syntax zone for writing out
text to a stream?

 Paul Prescod - Not encumbered by corporate consensus
New from Computer Associates: "Software that can 'think', sold by 
marketers who choose not to."