String concatenation vs. string formatting

Thorsten Kampe thorsten at thorstenkampe.de
Sat Jul 9 00:23:42 EDT 2011


* John Gordon (Fri, 8 Jul 2011 20:23:52 +0000 (UTC))
> I prefer this usage:
> 
>   logger.error('%s could not be stored - %s' % \
>     (self.preset_file, sys.exc_info()[1]))

The syntax for formatting logging messages according to the 
documentation is:

Logger.error(msg, *args) 

NOT

Logger.error(msg % (*args)) 

Thorsten



More information about the Python-list mailing list