On 2007-07-25, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > You can use the built-in dir() function to determine whether or not > the __iter__ method exists:
I think you might have to check for __getitem__, also, which may support the sequence protocol. > def is_iterable(thing): > return '__iter__' in dir(thing) So then: def is_iterable(thing): return '__iter__' in dir(thing) or '__getitem__' in dir(thing) Speaking of the iter builtin function, is there an example of the use of the optional sentinel object somewhere I could see? -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list