[Python-ideas] Tweaking closures and lexical scoping to include the function being defined

Eric Snow ericsnowcurrently at gmail.com
Sat Oct 1 08:16:06 CEST 2011


On Fri, Sep 30, 2011 at 12:14 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> However, I'm not seeing a lot to recommend that kind of syntax
> over the post-arguments '[]' approach.

Agreed, though Jan made some good points about this.  But my concern
with the decorator approach is that it isn't visually distinct enough
from normal decorators.  The @(...) form does help though.

How about another approach:

   given:
       lock=threading.RLock())
   def my_foo():
       with lock:
           "do foo"

or

   def my_foo():
       with lock:
           "do foo"
   given:
       lock=threading.RLock())

It's an idea that just popped into my head (*cough* PEP 3150 *cough*).
 But seriously, I don't think statement local namespaces have come up
at all in this super-mega thread, which surprises me (or I simply
missed it).  Doesn't it need a "killer app".  Maybe this isn't
"killer" enough, but it's something! :)

-eric



More information about the Python-ideas mailing list