Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9118 > unrolled thread

Re: String concatenation vs. string formatting

Started byAndrew Berg <bahamutzero8825@gmail.com>
First post2011-07-09 17:02 -0500
Last post2011-07-09 17:02 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: String concatenation vs. string formatting Andrew Berg <bahamutzero8825@gmail.com> - 2011-07-09 17:02 -0500

#9118 — Re: String concatenation vs. string formatting

FromAndrew Berg <bahamutzero8825@gmail.com>
Date2011-07-09 17:02 -0500
SubjectRe: String concatenation vs. string formatting
Message-ID<mailman.806.1310248971.1164.python-list@python.org>
On 2011.07.09 06:06 AM, Vinay Sajip wrote:
> In a logging context at least, using the form like
>
> logger.debug("formatting message with %s", "arguments")
>
> rather than
>
> logger.debug("formatting message with %s" % "arguments")
How would I do that with the newer formatting? I've tried:
> logger.info('Binary preset file {file} successfully stored.', {file :
> queue[0].preset_file})
(global name 'file' not defined)
and
> logger.info('Binary preset file {file} successfully stored.',
> file=queue[0].preset_file)
(unexpected keyword 'file')

> By the way, logging primarily uses %-formatting instead of the newer
> {}-formatting, because it pre-dates {}-formatting. In more recent versions of
> Python, all of Python's three formatting styles are supported - see
I've noticed. :-)
> log_formatter = logging.Formatter('{asctime} - __main__ - {funcName} -
> line {lineno} - {levelname} - {message}', style='{')

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web