On Sat, 2005-09-03 at 09:15, Paul Moore wrote:

> OK, how about a *single* builtin, named "print", which works something
> like Nick Coghlan's proposal (I'm happy to fiddle with the details,

So I've now read Nick's wiki page and here are my comments:

First, while I think you'll need two builtins, they won't be
distinguished by their end-of-line behavior.  That is easily handled by
a keyword argument.

More important IMO will be the need to distinguish whether you want a
format string or not.  The two use cases I came up with (and posted
about previously) are:

print 'obj:', obj, 'refcounts', sys.getrefcount(obj)
print 'obj: %s, refcounts: %s' % (obj, sys.getrefcount(obj))

Despite that these look superficially equivalent, they really aren't. 
The problem is that if you used one function, you'd have to make the
format string selectable by keyword argument.  But that's really ugly
because the focus of the operation /is/ the format string, and you
really want that to come first, not last, in the function call order. 
So the alternative is to do some magical interpretation of the first
argument to decide whether it's a format string or not.  Ick!

So I think it's best to have two builtins:

print(*args, **kws)
printf(fmt, *args, **kws)

I would also /require/ that any behavior changing keyword arguments
/not/ be magically inferred from the positional arguments.  So you'd
have to explicitly spell 'nl=False' or "stream=fp" if that's what you
wanted.

-Barry

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to