[Python-Dev] locals(), closures, and IronPython...
Aahz
aahz at pythoncraft.com
Tue Mar 6 16:52:31 CET 2007
On Tue, Mar 06, 2007, Andrew Dalke wrote:
> On 3/5/07, Guido van Rossum <guido at python.org> wrote:
>>
>> I don't know too many good use cases for
>> locals() apart from "learning about the implementation" I think this
>> might be okay.
>
> Since I'm watching this list for any discussion on the traceback
> threads, I figured I would point out the most common use I know
> for locals() is in string interpolation when there are many local
> variables, eg:
>
> a = "spam"
> b = "egg"
> ...
> y = "foo"
> z = "bar"
>
> print fmtstr % locals()
I'll second this one.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"I disrespectfully agree." --SJM
More information about the Python-Dev
mailing list