"print" as function not statement

Dietrich Epp dietrich at zdome.net
Tue Mar 16 19:29:05 EST 2004


On Mar 10, 2004, at 4:52 AM, Peter Otten wrote:

> My first thought was to add separator and newline attributes to file 
> objects
> and keep print just like it is, but the print object is more flexible. 
> You
> could easily add further extensions, e. g.
>
> print.set_format(float, "%.2f")
> print.set_format(str, "%r")

Ah, just so you know, 'print' doesn't format anything.  It just puts 
everything through the str() function.  If you need fancier formatting, 
instead of turning the print function into a glorified printf, look to 
the formatting operator or the fpformat module.





More information about the Python-list mailing list