Reputation: 2287
Are there any built-in Python classes that are not instances of type
metaclass?
>>> type(list)
<type 'type'>
>>> type(dict)
<type 'type'>
>>> type(some_builtin_python_class)
<type 'some_type_other_than_type'>
Upvotes: 2
Views: 233
Reputation: 366003
Depends what you mean by "built-in". If you mean any of the C-implemented (in CPython) classes exposed as builtins (and in builtin
), then no, none of them have a different metaclass.*
But there are definitely classes in the stdlib that do. For example:
>>> type(collections.abc.Iterable)
abc.ABCMeta
To clarify: Other metaclasses are of course subclasses of type, so, by the normal inheritance rules, it's still true that isinstance(Iterable, type)
—but it's not true that type(Iterable) == type
. Which is what you were asking for in your question—a type for which type(T)
returns <type 'some_type_other_than_type'>
.
* Not in 3.x, at any rate. Things were different in 2.x, where there were classic classes, and, once upon a time, "fake classes" that were actually functions that looked like type
instances but weren't, and returned instances of a hidden type
instance when called.
Upvotes: 4