identity = lambda x: x -- a Pythonic idiom?
George Demmy
gdemmy at layton-graphics.com
Sat Nov 17 17:45:46 EST 2001
More information about the Python-list mailing list
Sat Nov 17 17:45:46 EST 2001
- Previous message (by thread): identity = lambda x: x -- a Pythonic idiom?
- Next message (by thread): Question to those who know both Java & Python pretty well...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Erik Max Francis <max at alcyone.com> 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. Thanks, G -- George Demmy
- Previous message (by thread): identity = lambda x: x -- a Pythonic idiom?
- Next message (by thread): Question to those who know both Java & Python pretty well...
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list