Utility Classes :: IsIterable
Overview
The IsIterable utility class is used to specify that the object must be iterable, that is, that the object can be used in for loops and list comprehensions, like so:
@accepts(IsCallable(), IsIterable()) @returns(IsIterable()) def map(func, iter): return [func(obj) for obj in iter]
or
@accepts(IsCallable(), IsIterable()) @returns(IsIterable()) def map(func, iter): processed = [] for obj in iter: processed.append(func(obj)) return processed
Where IsCallable() is the IsCallable() utility class.
Details
The IsIterable() constructor accepts only the self parameter.
IsIterable instances will always compare equal (==) to one another.