[BangPypers] diffrerence between lambda function and ordinary one

Zubin Mithra zubin.mithra at gmail.com
Fri Aug 6 16:34:08 CEST 2010


>
>
> i was writing some basic code . for understanding lambda functions , but
> couldnt understand the difference between a lambda function and an ordinary
> function.
>
> for example
>
> >>>def f (x): return x**2
> ...
> >>> print f(8)
> >>> 64
> >>> g = lambda x: x**2
> >>>
> >>> print g(8)
> >>> 64
>
> wats a need for using lambda functions ..?
>

Lambda functions are generally used where you need one liner functions to
get things done. It was a feature which was considered for removal in py3k
but there were too many people who loved the feature. :)

Personally I feel that lambda functions are great as long as they are
readable.

zm


More information about the BangPypers mailing list