print with no newline

Jp Calderone exarkun at divmod.com
Fri Sep 3 11:32:27 EDT 2004


Tim Golden wrote:
> [Jp Calderone]
> | Basically, print is only meant to help people new to the 
> | language get started ;)  
> | It often does what will make life easiest for someone who is 
> | just getting into things, but which is otherwise confusing, expected, 
> | special-casey, or otherwise undesirable.  I mean, the whole 
> | existence of the keyword "print" is an inconsistency, right?  
> | One could quite reasonably expect print to be a function.
> 
> This point of view comes up from time to time on the list
> and for the life of me I can't buy into it. Putting aside
> the obviously tongue-in-cheek implication that only beginners
> would use print, I have almost never found print to be
> "confusing... or otherwise undesirable". It does exactly
> what I expect it to do with the minimum of syntactic clutter.

   Have you ever run into or relied on the behavior that started this 
thread?  I can't imagine how you might deduce that behavior from the 
rest of print's behavior.

   Let me also clarify - I use print all the time.  It's quite 
convenient and rarely does something other than what I intend.  That 
said, almost all my uses of it are for debugging or in the interactive 
interpreter when investigating some object or behavior.  I can't 
remember the last time I left it in a real program.

> [snip]
> 
> I would *not* reasonably expect print to be a function. Why
> should it be? Certainly any move to remove the print statement
> from the language or to replace it by a print function would
> get my thumbs-down (or whichever way round the Romans did it).
> 

   Lots of other people expect it to be a function.  I can't count the 
number of times I've read this in someone's code:

     print(x)

   That said, I don't propose changing it.

   Jp



More information about the Python-list mailing list