Why inspect.isclass says iter() a class?

Calvin Spealman cspealma at redhat.com
Wed Apr 10 15:23:09 EDT 2019


Because it is. Many things are classes. calling itertools.chain(a, b)
creates an itertools.chain instance that you can iterate over. What else
did you think it would be?

On Wed, Apr 10, 2019 at 3:17 PM Arup Rakshit <ar at zeit.io> wrote:

> From docs https://docs.python.org/3/library/itertools.html#itertools.chain
> I see that itertools.chain is defined as a function. But then why
> inspect.isclass(chain) is saying it as class.
>
> from itertools import chain
>
> inspect.isclass(chain)
> # True
>
>
> Thanks,
>
> Arup Rakshit
> ar at zeit.io
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspealma at redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>


More information about the Python-list mailing list