string formatting
Terry Reedy
tjreedy at udel.edu
Sat May 7 03:55:01 EDT 2011
On 5/6/2011 8:09 PM, Chris Angelico wrote:
> On Sat, May 7, 2011 at 6:54 AM, Terry Reedy<tjreedy at udel.edu> wrote:
>> def emsg(x):
>> if isinstance(x,tuple):
>> x = (x,)
>> print(The following object caused a proplem: %s" % x)
>>
>
> Couldn't you just do that unconditionally?
> print(The following object caused a proplem: %s" % (x,))
I guess so, as long as one remembers the ','. That does not obviate the
fact that % x is an attractive nuisance which works until it does not.
--
Terry Jan Reedy
More information about the Python-list
mailing list