[Python-ideas] Anonymous blocks (again):

Juancarlo Añez apalala at gmail.com
Sun May 12 08:11:32 CEST 2013


On Sun, May 12, 2013 at 12:45 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> In current Python, decorator abuse can be a reasonable option:
>
>    @closure
>    def block():
>         self.rule()
>         self.ast['rules'] = self.last_node
>

Buf for that to work, you'd still have to call:

block()

And that would make it:

   @closure
   def block():
        self.rule()
        self.ast['rules'] = self.last_node
   block()

Which I think makes little sense to a human reader, at least not in the
pythonic way, and less so when compared to my (map/reduce..functional).


closure(block)


Your proposal was the approach I previously used in Grako, and I deprecated
it in favor of the currently standing state of things in Python, which is:

*If you want an executable block of code you can iterate upon, then define
a (non-anonymous) function, and pass it to the iterator.*


Cheers.

-- 
Juancarlo *Añez*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130512/aa04f09f/attachment.html>


More information about the Python-ideas mailing list