Why use "locals()"

steve steve at lonetwin.net
Wed Sep 16 09:33:47 EDT 2009


On 09/14/2009 08:36 AM, Sean DiZazzo wrote:
> I have never used a call to "locals()" in my code.  Can you show me a
> use case where it is valuable and Pythonic?
>
You've received other answers, but just purely from the 'zen' perspective, there 
is a nice clean yin/yan symmetry about globals() Vs locals() after all...

  Namespaces are one honking great idea -- let's do more of those!

I am sure someone can come up with an example of where having this very 
distinction is useful ...I am too lazy to dream up one myself right now.

cheers,
- steve

-- 
random non tech spiel: http://lonetwin.blogspot.com/
tech randomness: http://lonehacks.blogspot.com/
what i'm stumbling into: http://lonetwin.stumbleupon.com/



More information about the Python-list mailing list