[TIP] Teaching pylint about keyword placeholders in string formatting
Barry Warsaw
barry at python.org
Wed Jul 15 05:01:47 PDT 2009
On Jul 15, 2009, at 7:44 AM, Marius Gedminas wrote:
> spangulate("%(warble)s: %(foo)s%(bar)s [%(baz)d]"
> % dict(warble=warble, foo=foo, bar=bar, baz=baz))
>
> and therefore never have the problem with pylint. (Though I prefer
> pyflakes. Fewer erroneous warnings, or at least I got that
> impression.)
>
> Strangely enough, playing with sys._getframe(1).f_globals is okay in
> my
> book, if I really need it.
In fact, I do that all the time, since it's hooked into my i18n
framework. And I use $-name substitutions (string.Template), e.g.
spangulate(_('$warble: ${foo}${bar} [$baz]'))
and yeah, this doesn't make pylint very happy, but it makes
translators happ(ier)!
-Barry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 832 bytes
Desc: This is a digitally signed message part
Url : http://lists.idyll.org/pipermail/testing-in-python/attachments/20090715/ffc27a91/attachment.pgp
More information about the testing-in-python
mailing list