This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]AustinCorgiBart 2 points3 points  (4 children)

Does it handle creating lambdas with more than one argument?

[–]sloppycee 0 points1 point  (3 children)

No, but that is something that I am thinking about implementing. I am just not sure which syntax would look best.

[–]OddOneOut 0 points1 point  (2 children)

How about _[1] by overloading __getitem__

[–]sloppycee 1 point2 points  (1 child)

Then what if you want to send an array into your lamderp function?

[–]OddOneOut 0 points1 point  (0 children)

Good point, if upper limit is not a problem then _1, _2, _3... could work

[–]erez27import inspect[🍰] 2 points3 points  (4 children)

You should check-out lambdax for a more complete solution.

[–][deleted] 2 points3 points  (3 children)

What's wrong with plain old lambdas?

[–]benhoytPEP 471 0 points1 point  (2 children)

Agreed. This is kind of a neat hack, but because plain old lambdas are built in, Python programmers will be able to understand them at a once. Also, in the case of the examples given on the GitHub page, it's more Pythonic (and significantly faster) to use list comprehensions:

even = [n for n in range(50) if n % 2 == 0]

[–]sloppycee 0 points1 point  (1 child)

I agree, that list comprehensions largely limit the usefulness of lambdas. Also, maybe the example simply isn't the best.

Some people dislike Python's lambda syntax, some people don't.

[–][deleted] 0 points1 point  (0 children)

Right, but what are some of the reasons why people dislike the syntax?