[Python-ideas] PEP for issue2292, "Missing *-unpacking generalizations"

Joshua Landau joshua.landau.ws at gmail.com
Sat Jul 6 20:32:33 CEST 2013


On 6 July 2013 17:40, SpaghettiToastBook . <spaghettitoastbook at gmail.com> wrote:
> I like the PEP overall, and it seems to cover everything.

Ty.

> I'm not sure
> that the function definition changes should be included due to
> backward incompatibility.

I decided when writing this that I'd just go and include everything,
seeing as it's easier to remove things I've included than add things I
haven't.

> I do have one question about this line:
>
> "- ``lambda *args, last: ...`` no longer requires ``last`` to be a
> keyword only argument"
>
> What exactly is backward incompatible about this change?

To be particular, every extension to syntax is backward incompatible.
Imagine any case where you have:

try:
    exec("now-valid-syntax")
except SyntaxError:
    expected_to_happen()

That's obviously far-fetched, but the point is across. Any code that
requires it to fail when "last" isn't passed in will break. For
example, code that "builds" arguments to the function using input from
the user (Ranger might do this, I'm not sure). It's also a bit
far-fetched, but it might count. It might also change the behaviour of
certain types of currying.

Probably the most important change is that "(lambda *args, last=None:
print(args, last))(1, 2, 3, 4, 5)" prints "(1, 2, 3, 4, 5) None",
whereas with the PEP as it is will print "(1, 2, 3, 4) 5". This is
quite a nonobvious change, so I should add it to the PEP.


> Also, on line 34, "keywords" should be "keyword" instead.

Additionally, "A further extension to comprehensions is a logical and
necessary extension." (line. 108) is quite a silly thing to write.
I'll upload these fixes in-bulk when I update the PEP.


More information about the Python-ideas mailing list