Adding print-style function calls, and preproc plugins

Terry Reedy tjreedy at home.com
Thu Aug 30 16:56:30 EDT 2001


"Gerson Kurz" <gerson.kurz at t-online.de> wrote in message
news:3b8e6d04.14344968 at news.t-online.de...
> Well please remember what my original intent was: writing my own
print
> function - er - statement.

In Python, like it or not, statement keywords are quite different from
function names, and the difference goes quite deep in both the
language definition and implementation.   Pretending otherwise only
leads to pain (as in beating one's head against a wall 8-).  You are,
of course, free to write your own function or method to do what you
want - which is what you should do from the beginning if you want
total control.

The print statement is not necessary, but is provided as a convenience
for output thru sys.stdout.write() with a format that is often good
enough, especially beginners and for interactive use or debugging.  It
was not meant to be a general replacement for format expressions,
file.write() and other code.
...
> But please, my problem was that I had to modify print's behaviour,
and
> couldn't do so, because by going from "print" to a function, you
have
> to enclose the arguments in brackets.

You *can* modify print statement behaviour -- by modifying the
interpreter at the place where its behaviour is determined (which is
less than what you were proposing that someone else do).  'Having' to
add parens (not brackets) is different from 'could not'.

Terry J. Reedy






More information about the Python-list mailing list