On Wed, Aug 7, 2013 at 12:02 AM, Terry Reedy <tjre...@udel.edu> wrote: > 3) The code falls into an infinite loop or recursion. > > The solution is to think before looping or recursing. This often involves > value checking (non-negative int or non-fractional float, for instance) > rather than type checking in the usual static type-checking sense.
Yeah, there aren't many languages that let you declare that the argument must be a positive integer. That's just something you have to test for manually. > One also needs to be careful about passing unbounded iterators to other > functions and remember that unboundedness is contagious. (filter(pred, > unbounded_iterator) is an unbounded iterator). Again, this is a 'value' or > implicit sub-type issue rather than a explicit, visible 'type' issue. Not quite always; I'd say that unboundedness is as contagious as IEEE Infinity. Lots of operations on infinity will yield infinity, but a few won't. itertools.islice can guarantee a finite iterator, and takewhile may terminate. But yes, with filter() it certainly is. ChrisA -- http://mail.python.org/mailman/listinfo/python-list