Chris Rebert <[email protected]> writes:
> print "{solo} was captured by {jabba}".format(**locals()) # RIGHT
I tend to use ‘u"foo {bar} baz".format(**vars())’, since ‘vars’ can also
take the namespace of an object. I only need to remember one “give me
the namespace” function for formatting.
> You must use prefix-** in the call to unpack the mapping as keyword
> arguments. Note that using locals() like this isn't best-practice.
Who says so, and do you find their argument convincing? Do you have a
reference for that so we can see why?
--
\ “If you write the word ‘monkey’ a million times, do you start |
`\ to think you're Shakespeare?” —Steven Wright |
_o__) |
Ben Finney
--
http://mail.python.org/mailman/listinfo/python-list