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

George Demmy gdemmy at
Sat Nov 17 23:45:46 CET 2001

Erik Max Francis <max at> writes:

> George Demmy wrote:
> > My understanding of Pythonic truth anything other than None, (), [],
> > {}, '', and 0 is true. I don't know what mathematical truth is -- got
> > a approachable reference for an interested non-mathematician?
> When you're using filter, the function you need maps an object to a
> truth value, but the identity function maps an object to itself.  In
> Python this happens to be the same thing, but what you "really mean" is
> lambda x: operator.truth(x).

Ahhh... OK. I see your point, and I agree. Your example is excellent.



George Demmy

More information about the Python-list mailing list