0

Why does type(type) and type(range) return <class 'type'>?

Question on python types

26th Feb 2019, 10:21 AM
Osinachi Chukwujama
Osinachi Chukwujama - avatar
1 Answer
+ 1
Because type and range are type definitions, so you get exactly this: 'What you gave me here is of type "type"'. You could do the same with your self-defined classes: class C: ... then look at type(C), and you'll hear it's a type. If you do type(range()), you get a different result, because now you don't check the class but an instance of that class.
26th Feb 2019, 12:47 PM
HonFu
HonFu - avatar