YA string interpolation and printing idea

Paul Rubin http
Sat Jan 17 05:52:08 CET 2004


Erik Max Francis <max at alcyone.com> writes:
> Why in the world would you want that?  Printing methods go on the things
> that do work of printing, which are file-like objects, not strings. 

To give a convenient way to do interpolated printing.  Practicality
beats purity.  Another approach I like is to define a unary minus
operation on strings, which does interpolation.  But that's gone
nowhere when I've proposed it in the past.  Maybe if type/object
unification proceeds far enough, we'll someday be able to define our
own operations on builtin objects like strings.

> And, on file-like objects, that method is called `write'.

'write' does what it should, which is writes out exactly the
characters you give it.  Python's print statement does the same plus
adds a newline, and people have gotten used to that misbehavior
(explicit is better than implicit), so I made an accomodation for that.



More information about the Python-list mailing list