identity = lambda x: x -- a Pythonic idiom?

Andrew Dalke dalke at dalkescientific.com
Sat Nov 17 11:48:24 EST 2001


George Demmy:
>identity = lambda x: x # like this in practice (lazy)
>
>def identity(x): # Pythonic -- shows up in profiler, etc
>    return x
>
>data = filter(identity, crufty_list)

Isn't this the same as operator.truth?

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list