14 Aug
2020
14 Aug
'20
2:38 p.m.
On Fri, Aug 14, 2020 at 6:46 PM Marco Sulla
Many times I want a function parameter that is an iterable but not a string. from collections.abc import Iterable
if isinstance(var, Iterable) and not isinstance(var, str): # put yuour code here
Well, that line of code asks if something is an iterable and not a string. It perfectly captures the intent described in your opening statement. I'd say go with it. IMO the collections module isn't really right for something like that, but if you really need a helper function for this one-liner, then I'd say having one in your own code is perfectly reasonable. ChrisA