On Sat, 2005-09-03 at 12:51, James Y Knight wrote: > On Sep 3, 2005, at 11:32 AM, Barry Warsaw wrote: > > > So I think it's best to have two builtins: > > > > print(*args, **kws) > > printf(fmt, *args, **kws) > > It seems pretty bogus to me to add a second builtin just to apply the > % operator for you. I've always really liked that Python doesn't have > separate xyzf functions, because formatting is an operation you can > do directly on the string and pass that to any function you like. > It's much cleaner...
Actually, we probably only /need/ printf(), and certainly for C programmers (are there any of us left? ;), I think that would be a small conceptual leap. The motivation for keeping a non-formatting version is for simple cases, and beginners -- both of which use cases should not be dismissed. The reason I proposed two versions is because I'd really dislike putting the format string in any position other than the first positional argument, and I can't think of a way to definitively distinguish between whether a first arg string is or is not a format string. One possible way out is to define a string literal that creates Template strings, and then make the Template string syntax rich enough to cover today's %-substitutions. Then if the first argument is a Template, you do printf()-like output otherwise you do print()-output. -Barry
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