.format vs. %
Terry Reedy
tjreedy at udel.edu
Mon Jan 2 05:29:58 EST 2012
More information about the Python-list mailing list
Mon Jan 2 05:29:58 EST 2012
- Previous message (by thread): .format vs. %
- Next message (by thread): .format vs. %
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 1/1/2012 4:11 PM, Miki Tebeka wrote:
>>>>> s = "{0} {1} {2} {3}"
>>>>> s.format(1, 2, 3, 4)
>> '1 2 3 4'
> Or even
> In [4]: fmt = '{0} {1} {2} {3}'.format
> In [5]: print(fmt(1, 2, 3, 4))
> 1 2 3 4
I have done this, except for using a more informative name, like 'emsg'
for error message.
except XError as e:
print(emsg(a,b,c,e))
makes for pretty clear code.
--
Terry Jan Reedy
- Previous message (by thread): .format vs. %
- Next message (by thread): .format vs. %
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list