[Tutor] Re: [Edu-sig] style question
Thu, 21 Feb 2002 07:18:38 -0800
>Personally, I think it's ok to add booleans; I feel it's
>fairly safe to assme that equality testing returns an integer.
OK, and I get the subtle difference now.
I'd likely still go for a list comprehension over a
map-lambda, esp. when teaching newcomers. Call me
And note: if we're so paranoid as to distrust that ==
might be reliable, given it can be overridden by an
object, so might % be overidden, messing up the filter-
based test as well:
>>> class T:
self.val = val
return self.val == other.val
>>> t0 = T(1)
>>> t1 = T(45)
>>> [t0,t1] # so, no evens, yes?
>>> len(filter(None,[i%2==0 for i in [t0,t1]])) # think again!
Just can't be too careful. :-D