On Fri, 14 Aug 2020 at 11:10, Chris Angelico wrote:
> 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.
In my experience I used it a lot, and I s
On Fri, Aug 14, 2020 at 10:43:31AM +0200, Marco Sulla wrote:
> Many times I want a function parameter that is an iterable but not a
> string. Usually I do:
>
> try:
> var.__iter__
> except AttributeError:
> # not an iterable
> else:
> try:
> var.isascii
> except AttributeEr
On Fri, Aug 14, 2020 at 6:46 PM Marco Sulla
wrote:
>
> 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