I'd just use `pylearn2.utils.is_iterable`