[Python-Dev] Replacement for print in Python 3.0

Barry Warsaw barry at python.org
Mon Sep 5 04:07:18 CEST 2005


On Sat, 2005-09-03 at 22:08, Nick Coghlan wrote:

> > See a (very quick and very dirty ;) strawman that I just posted to the
> > wiki.  I think this has some interesting semantics, including the
> > ability to control the separator inline in a C++-like fashion.  The
> > writef() version also accepts string.Templates or %s-strings as its
> > first argument.  I'm not sure I like reserving 'to' and 'nl' keyword
> > arguments, and not having the ability to print Separator instances
> > directly, but OTOH maybe those aren't big deals.
> 
> The latter problem is easily solved by calling str() at the point of the call
> so that write() never sees the actual Separator object. 

Good point.

> However, this 'inline'
> behaviour modification has always annoyed me in C++ - if you want this kind of
> control over the formatting, a format string is significantly clearer.

You're probably right about that.

> Separating the formatting out into a separate functions like this addresses
> your concern with the namespace conflict for 'to' and 'nl', and also makes the
> 'format' builtin more generally useful, as it can be used for cases other than
> direct output to a stream.

The downside being that you have to type more to get the behavior you
want.  It does have the advantage of solving the namespace problem.

-Barry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: This is a digitally signed message part
Url : http://mail.python.org/pipermail/python-dev/attachments/20050904/b9eac741/attachment.pgp


More information about the Python-Dev mailing list