Cause you're apparently not aware that I was demonstrating a use-case for lambdas as one-off functions that are passed to other functions (which is an abstract concept from the particular function used), and you didn't demonstrate how list comprehensions or generators make them not-needed. Of course, that's because it was a leading question and the answer is that the concepts are orthogonal so it cannot be demonstrated.
That was not ad hominem, because what you wrote is indeed half-baked hackery.
Nobody said it cannot be done the way you did it. You were just pointed at the shortcomings of your approach and that the Python community generally prefers stupidly simple, easy to understand solutions. Using magic attributes to argue against it just makes it worse - remember this is a thread about idiomatic Python code bases.
> Nobody said it cannot be done the way you did it. You were just pointed at the shortcomings of your approach
I "addressed" the shortcomings of "my approach" by showing that Python (the language, not the community) allows you to access and manipulate the data you claimed was important and missing.
I don't believe it is necessary for most simple functions to know what their name is. I do believe the demonstrated code is self documenting enough to not require a documentation string. You made those "requirements". I never claimed that every function must be a lambda - you seem to be implying I am, so I am explicitly stating that I do not.
Here's a place where you really do need a named function (due to deficiencies in Python's lambda implementation):
>>> def named_lambda(procedure, name, documentation=''):
... procedure.__name__ = '<lambda {}>'.format(name)
... procedure.__doc__ = documentation
... return procedure
...
>>> absolute_path = named_lambda(lambda path: path if path.startswith('/') else '/' + path, 'absolute_path', 'Return the absolute unix path from a given path name')
>>> absolute_path.__name__
'<lambda absolute_path>'
>>> absolute_path.__doc__
'Return the absolute unix path from a given path name'
Of course, that's completely silly... since the point of a lambda function generally is that the function is generally small enough and short-lived enough that it does not need a name or documentation.
> the Python community generally prefers stupidly simple, easy to understand solutions.
Which, despite your protests, includes using lambdas!
> Using magic attributes to argue against it just makes it worse - remember this is a thread about idiomatic Python code bases.
How else does a function "know its own name" unless it uses the "magic" attribute "__name__"? Oh, you prefer "func_name"? That's cute:
So in this comment I am replying to, it is a bad thing that I made use of "__name__", but in the comment THAT was replying to, it was a bad thing that I did NOT use "__name__" or its linked "func_name". That's how you move goal posts!
Ad hominem? I guess I win.
> List comprehensions and generator expressions have replaced all need for map, filter, and lambdas
Please explain how list comprehensions and generators have replaced the need for lambdas.
Your "distaste" of functional programming constructs is right up there with Guido's.