why would this print 'True'?

Neal Becker ndbecker2 at gmail.com
Mon May 11 08:51:35 EDT 2015


from itertools import ifilter

if all (hasattr (b, 'test') for b in ifilter (lambda b: b < 10, [1,2,3,4])):
    print 'True'

same result using filter instead of ifilter.

hasattr (b, 'test') where b is 1, 2, 3... should all be False.  So why does 
this print True?

-- 
Those who fail to understand recursion are doomed to repeat it




More information about the Python-list mailing list