this morning I come out a weird ideal. as we know, in python everything is objects include class and function.
DONT ask why I want to do it. it is an experiment for playing around python. I knew it is inherited from instance.
let's try:
kk=dict()
print dir(dict)
print dir(kk)
output of them are same
class yy(dict): pass ---ok
class zz(kk) : fail ---error
TypeError: Error when calling the metaclass bases
dict expected at most 1 arguments, got 3
Can anyone explain me in depth why I got this error message ?
again. if possible, please explain how python output this error message ?
It's because you need to inherit from a
type.dictis a type,dict()is not, it's an instance of a dict.types type istype, and all instances of type are of typetype- their instances are not.