[Python-ideas] Anonymous blocks (again):

Nick Coghlan ncoghlan at gmail.com
Mon May 13 01:40:57 CEST 2013


On 13 May 2013 03:23, "Juancarlo Añez" <apalala at gmail.com> wrote:
>
>
> On Sun, May 12, 2013 at 10:09 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>>
>> > I've tried everything, so I'm pretty sure that there's no clean
solution in
>> > 2.7/3.3.
>>
>> Correct. This is why PEP 403 exists.
>
>
> PEP 403 sucks!
>
> It's a very ill attempt at replacing the need for anonymous blocks, which
could be done syntax very like the current one.

Anonymous blocks in Ruby depend on the convention that the block is always
the last positional argument. Python has no such convention, thus any
"block like" solution will require a mechanism that allows the user to tell
the interpreter where the trailing callable should be referenced in the
preceding simple statement.

Earlier versions of PEP 403 used a magic symbol for this, but that ended up
being ugly and non-obvious. Thus, I changed it to the current explicit
forward reference. For throwaway callbacks, using a short meaningless name
like "f" should be sufficiently brief, and in many cases a more meaningful
name may be used in order to make the code more self-documenting.

Now, do you have any constructive feedback on the PEP that still accounts
for Python's lack of a standard location for passing callables to
functions, or is this reaction simply a matter of "I don't want to have to
type 'f' twice because I don't have to do that in other languages"?

Regards,
Nick.

>
> ATIAIHTSAT!
>
> This thread is closed, AFAIC. I am in peace with the must-be-functions of
Python blocks. Smarter people than me will figure things out.
>
> Cheers,
>
> --
> Juancarlo Añez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130513/a978b9c6/attachment.html>


More information about the Python-ideas mailing list