filter() and booleanness

Oleg Broytmann phd at phd.pp.ru
Sun Jan 20 08:05:48 EST 2002


Hi!

   Russian? Already subscribed to the Russian Python and Zope mailing
liit? zope.net.ru, http://zope.net.ru/About/mail-list/

> Hi there, the following two calls will both print ('hi', 'there') due
> to None being substituted for `identity function' (as the docs say):
> 
> print filter(None, ('hi', None, 0, 'there'))
> print filter(lambda x: x, ('hi', None, 0, 'there'))
> 
> Then I thought I'd clamp the x to [0..1] but things like x != 0 missed
> None and x != None missed 0. :) Now I have lambda x: not not x, is it
> bulletproof? (it seems to work).

   But what do you want to achieve?

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list