> On Thu, 21 Apr 2005 09:59:54 -0500, Larry Bates > <[EMAIL PROTECTED]> wrote: > >>2) Or if you not you could see if the argument has next and >>__iter__ methods (more general solution) >> >>if hasattr(arg, 'next') and not hasattr(arg, '__iter__'): >> # perform work on iterable
The 'not' is a mistake and should be deleted. Iterators *do* have __iter__ methods, as suggested by the previous sentence. But anyway, I believe strings (or some builtin) still use __getitem__ instead of __next__, so this test is not adequate for everything. Terry J. Reedy -- http://mail.python.org/mailman/listinfo/python-list