What is islambda function in python
Question: Can anyone help me understanding this:

    
    
    def isalambda(v):
        return isinstance(v, type(lambda: None)) and v.__name__ == '<lambda>'
    


Answer: The function tests if a function object was created using a `lambda`
statement:

    
    
    >>> l = lambda: None
    >>> l
    <function <lambda> at 0x1020ae0c8>
    >>> l.__name__
    '<lambda>'
    

`lambda` expressions create a regular function object with the name set to
`<lambda>` as there is no `def` statement naming the function.

It could just as well have used:

    
    
    from types import FunctionType
    
    def isalambda(v):
        return isinstance(v, FunctionType) and v.__name__ == '<lambda>'
    

or using
[`inspect.isfunction()`](http://docs.python.org/2/library/inspect.html#inspect.isfunction):

    
    
    from inspect import isfunction
    
    def isalambda(v):
        return isfunction(v) and v.__name__ == '<lambda>'
    

The test isn't foolproof; you can assign any string to the `__name__`
attribute:

    
    
    >>> def foo(): pass
    ... 
    >>> foo.__name__
    'foo'
    >>> foo.__name__ = '<lambda>'
    >>> foo.__name__
    '<lambda>'
    >>> foo
    <function <lambda> at 0x1020ae050>
    

