"print" as function not statement

Aahz aahz at pythoncraft.com
Wed Mar 10 05:43:22 EST 2004


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

Your arguments are persuasive, but I disagree with your conclusions.
Given that almost every programming language has something like "print"
built into it, we can't afford to drop that name.  I think you need to
find a path that permits mutation from a reserved word.

The other issue is that you're wrong to make print() a function.
Instead, it should be a callable object.  That way, the default print
object has state:

    print(a, b, c)
    print.set_output(my_file)
    print(a, b, c)
    print(x, y, z)
    print.set_separator(None)
    print("The value is: ", 3)

>	Debug-useful return value
>
>		As a convenience, if the show function is passed a
>		single object to show, it returns that object. If
>		it is passed more then one, it returns them as a
>		tuple. This can be very convenient in debugging
>		contexts. 

I'm in agreement with the person who said that this would be too
confusing in interactive mode.  Then again, if print is an object, it'd
be easy to set this behavior, too.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list