Why inspect.isclass says iter() a class?

Arup Rakshit ar at zeit.io
Wed Apr 10 15:25:36 EDT 2019


Well. I thought so far, all class in python is defined as CamelCase. A function can be a class to is something I am surprised. So does this mean, any callable function if produce an instance is called class in Python?


Thanks,

Arup Rakshit
ar at zeit.io



> On 11-Apr-2019, at 12:53 AM, Calvin Spealman <cspealma at redhat.com> wrote:
> 
> 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
> 
> 
> TRIED. TESTED. TRUSTED.




More information about the Python-list mailing list