On 2007-07-25, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> So there's no reliable way to test for "iterables" other than
> actually iterate over the object.

A TypeError exception is perhaps too generic for comfort in this
use case:

def deeply_mapped(func, iterable):
  for item in iterable:
    try:
      for it in flattened(item):
        yield func(it)
    except TypeError:
      yield func(item)

I'd be more confortable excepting some sort of IterationError (or
using an is_iterable function, of course). I guess there's always
itertools. ;)

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to