Is the right way to encapsulate non-iterable object in collection to make the same interface for iterable and non iterable objects?
import collections
def function(item):
if not isinstance(item, collections.Iterable):
item = [item]
process_collection(item)
The question is not dedicated to find out ways of determining if object is iterable, it is dedicated to find out the rightness of wrapping the non iterable object into a collection to use the same code for iterable and non iterable objects.