[Python-Dev] extended print statement, uPre-PEP
Paul Prescod
paul@prescod.net
Sun, 23 Jul 2000 10:10:00 -0500
"Barry A. Warsaw" wrote:
>
> >>>>> "PP" == Paul Prescod <paul@prescod.net> writes:
>
> PP> I don't see what proposal you are promoting that doesn't have
> PP> "@" in it?
>
> Forget about @, let's use >> instead.
Okay, but we're still inventing a new token that doesn't exist otherwise
in the language.
There are two reasons I oppose this.
1. On the one hand, we are making the print statement even more of a
special "syntax region" than it already is. In my opinion that's newbie
*unfriendly*. They learn how ">>" works in one place and then when they
look around for somewhere else to use it, they won't find it. I think
that that is profoundly unpythonic.
2. On the other hand, I oppose special case hacks *in general* because
when you solve a problem in one place, it doesn't solve it elsewhere.
The benefits of print are:
* no requirement for parens
* newline by default
* easy string coercion and interpolation
* less thinking about whitepspace
Okay, but what about when I want these features elsewhere in the Python
language? At least the last three should should be available everywhere
in Python.
In fact, we can do better than print:
Yours:
print >> sys.stdout, 'post to', listname, 'from', sender, \
'size=', len(msg)
My proposal:
writeln( $"post to ${listname} from ${sender} size=${len(msg)}" )
(or)
log.writeln( $"post to ${listname} from ${sender} size=${len(msg)}")
Note that I have more control over whitespace than in your example. I am
also reusing conventions from other popular languages. The interpolation
is available *wherever* string processing is done and it uses standard
Python features to redirect the output.
--
Paul Prescod - Not encumbered by corporate consensus
New from Computer Associates: "Software that can 'think', sold by
marketers who choose not to."