Hi All,

I was reading about meta programming in "Pro Django" book.

I came across the "type" class which will be acting as default meta class
for all other class. Also "type" metaclass is where actuall class object is
created

To dynamically create a class:
DynamicClass = type("DynamicClass", (object,), {'eggs' : 'spams'})

which means type's __init__ method accepts ClassName, bases(tuple) and
attrbs(dict) as args.


But in case of creating class via class definition("type" act as default
metaclass), the type is called by following syntax,

type(cls, classname, bases, attrbs)

My doubt is how it possible to pass "cls" as argument(as class is not even
created before calling meta class). Also how "type" is accepting different
args in two different cases?

Need help in understanding

Thanks in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to