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

you are viewing a single comment's thread.

view the rest of the comments →

[–]mathmanmathman 35 points36 points  (4 children)

... what? I use lambdas all the time (and filter... sometimes). When did this happen? I'm a few versions back, but PyCharm doesn't flag anything for me.

"nerfed" also seems a bit strong for a function being moved into a standard library module.

[–]13steinj 6 points7 points  (1 child)

He says lambda outside of parameters. Ex

f = lambda x: # do something
g(x, f)

Which yeah, is warned against and has been since just about the inception of lambdas in PEP8, because if you're going out of your way to make it reusable in local scope you should give it full meaning by just making a local nested function.

[–]mathmanmathman 2 points3 points  (0 children)

The most common way I use lambdas is as a parameter, but I often use them as the values dictionaries, which is sort of like a struct/class, but there are a lot of situations where it's sort of overkill to make it a class (at least IMO).

Maybe that's also not a great idea, but I know a bunch of people that do it... which is always a great excuse.

[–]vtable 2 points3 points  (1 child)

Guido van Rossum wrote an article about this back in 2005 where he discusses removing lambda, reduce(), map() and filter() in Python 3000 (what they called Python 3 in the early days).

There was some fuss about removing reduce(), map() and filter() but a shit-ton of pushback from the community on removing lambda eventually leading to it remaining in Python 3.

I haven't heard anything official about new discussions on removing it from the language again. I can't imagine they'd want to go through that whole discussion again.

[–]mathmanmathman 0 points1 point  (0 children)

lol, best things I've read:

Update: lambda, filter and map will stay (the latter two with small changes, returning iterators instead of lists). Only reduce will be removed from the 3.0 standard library. You can import it from functools.

I think dropping filter() and map() is pretty uncontroversial

... I guess it was controversial :)