Re: isiter builtin

2014-11-16 Thread Terry Reedy
On 11/16/2014 2:57 AM, Garrett Berg wrote: (how often have you iterated over a string?) Often enough, but perhaps more often have written functions for which a string is as valid an input as many other iterables. def cross(iterable, reiterable): for a in iterable: for b in reiter

Re: isiter builtin

2014-11-16 Thread Peter Otten
Garrett Berg wrote: > I have been working with python for a few years now, and two of my > favorite features about it are iterators and duck typing. The fact that > every iterator under the sun can be accessed with a simple for loop is one > of the most amazing features of python. > > However, th

Re: isiter builtin

2014-11-16 Thread Ben Finney
Garrett Berg writes: > However, there are times when I want to do type checking, and the > builtin function *isinstance* is of great use. I would advise that when you think you want type checking, you are probably being overly restrictive. > However, this function fails to be satisfactory in re

Re: isiter builtin

2014-11-16 Thread Chris Angelico
On Sun, Nov 16, 2014 at 6:57 PM, Garrett Berg wrote: > However, there are times when I want to do type checking, and the builtin > function isinstance is of great use. However, this function fails to be > satisfactory in returning whether the object is a valid iterator. The call > hasattr(obj, '__

isiter builtin

2014-11-16 Thread Garrett Berg
I have been working with python for a few years now, and two of my favorite features about it are iterators and duck typing. The fact that every iterator under the sun can be accessed with a simple for loop is one of the most amazing features of python. However, there are times when I want to do t