Re: Why use locals()

2009-09-18 Thread Simon Forman
On Mon, Sep 14, 2009 at 1:12 AM, Sean DiZazzo half.ital...@gmail.com wrote: Thanks for your explanation Steven.  I see how it can be valuable, but it seems to always break the second rule of Zen.  I don't really want to get into the code of debuggers, but I guess I can see how they might have

Re: Why use locals()

2009-09-18 Thread Sean DiZazzo
On Sep 18, 9:55 am, Simon Forman sajmik...@gmail.com wrote: On Mon, Sep 14, 2009 at 1:12 AM, Sean DiZazzo half.ital...@gmail.com wrote: Thanks for your explanation Steven.  I see how it can be valuable, but it seems to always break the second rule of Zen.  I don't really want to get into

Re: Why use locals()

2009-09-16 Thread Sion Arrowsmith
Gabriel Genellina gagsl-...@yahoo.com.ar wrote: s...@viridian.paintbox escribió: What I'm not clear about is under what circumstances locals() does not produce the same result as vars() . py help(vars) Help on built-in function vars in module __builtin__: vars(...) vars([object]) -

Re: Why use locals()

2009-09-16 Thread steve
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

Re: Why use locals()

2009-09-16 Thread Terry Reedy
Sion Arrowsmith wrote: Gabriel Genellina gagsl-...@yahoo.com.ar wrote: s...@viridian.paintbox escribi�: What I'm not clear about is under what circumstances locals() does not produce the same result as vars() . py help(vars) Help on built-in function vars in module __builtin__: vars(...)

Re: Why use locals()

2009-09-15 Thread Gabriel Genellina
En Tue, 15 Sep 2009 11:18:35 -0300, Sion Arrowsmith s...@viridian.paintbox escribió: Sean DiZazzo half.ital...@gmail.com wrote: What I'm not clear about is under what circumstances locals() does not produce the same result as vars() . py help(vars) Help on built-in function vars in module

Re: Why use locals()

2009-09-15 Thread Carl Banks
On Sep 15, 11:41 am, Gabriel Genellina gagsl-...@yahoo.com.ar wrote: En Tue, 15 Sep 2009 11:18:35 -0300, Sion Arrowsmith   s...@viridian.paintbox escribió: Sean DiZazzo  half.ital...@gmail.com wrote: What I'm not clear about is under what circumstances locals() does not produce the same

Re: Why use locals()

2009-09-14 Thread Chris Colbert
Given that python is devoid of types: Is the variable 'a' an int or a float at runtime?, explicit can only be taken so far. Personally, I use locals() when I work with Django. On Mon, Sep 14, 2009 at 7:42 AM, Sean DiZazzo half.ital...@gmail.com wrote: If you are willing to open your mind to

Re: Why use locals()

2009-09-13 Thread Sean DiZazzo
I have never used a call to locals() in my code.  Can you show me a use case where it is valuable and Pythonic? def print_item(item):      description = textwrap.fill(item.description, 40)      short = item.description.split('\n', 1)[0]      code = str(item.id).zfill(6)      print

Re: Why use locals()

2009-09-13 Thread Sean DiZazzo
On Sep 13, 9:11 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Sun, 13 Sep 2009 20:26:06 -0700, Sean DiZazzo wrote: On Sep 13, 8:18 pm, Steven D'Aprano ste...@remove.this.cybersource.com.au wrote: On Sun, 13 Sep 2009 20:06:51 -0700, Sean DiZazzo wrote: I have never

Re: Why use locals()

2009-09-13 Thread Carl Banks
On Sep 13, 9:54 pm, Sean DiZazzo half.ital...@gmail.com 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? def print_item(item):      description = textwrap.fill(item.description, 40)      short =

Re: Why use locals()

2009-09-13 Thread Carl Banks
On Sep 13, 10:15 pm, Carl Banks pavlovevide...@gmail.com wrote: Gabrielle's Whoops, very sorry about that typo, just how it rolled of the fingers. Ugh. Carl Banks -- http://mail.python.org/mailman/listinfo/python-list

Re: Why use locals()

2009-09-13 Thread Sean DiZazzo
If you are willing to open your mind to the possibility that some Pythonic things don't adhere to every Zen, then I would suggest that Gabrielle's examples are perfectly Pythonic shortcuts.  But if you don't want to use them, you don't have to, nobody is forcing you. It's a pretty small