Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90375 > unrolled thread

Re: why would this print 'True'?

Started byNeal Becker <ndbecker2@gmail.com>
First post2015-05-11 08:58 -0400
Last post2015-05-11 08:58 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: why would this print 'True'? Neal Becker <ndbecker2@gmail.com> - 2015-05-11 08:58 -0400

#90375 — Re: why would this print 'True'?

FromNeal Becker <ndbecker2@gmail.com>
Date2015-05-11 08:58 -0400
SubjectRe: why would this print 'True'?
Message-ID<mailman.360.1431349131.12865.python-list@python.org>
Nevermind - I found the answer.  I was trying this in ipython with pylab:

http://stackoverflow.com/questions/7491951/python-builtin-all-with-generators

Neal Becker wrote:

> 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web