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

Andrew Dalke dalke at
Sat Nov 17 19:24:55 CET 2001

George Demmy:
>operator.truth and the identity function are not exactly the same.
>operator.truth returns 1 if true, 0 if false. identity returns its
> argument

D'oh!  And duh!

>For filtering purposes, they have the same effect.

I was only thinking about its use in this context, forgetting
the larger sense.


More information about the Python-list mailing list