Re: Class construction

2013-10-22 Thread Neil Cerutti
On 2013-10-21, Marcin Szamotulski wrote: > So the process (with some simplifications) goes like this: > > 1. get metaclass: meta > 2. call meta.__prepare__ to get namespace (class __dict__) > 3. evaluate the class body in the namespace > 4. call meta with arguemnts: name, bases, na

Re: Class construction

2013-10-21 Thread Marcin Szamotulski
You can inspect the process in this way: >>> c = 'class A: pass' >>> code = compile(c, '', 'exec') >>> from dis import dis >>> dis(code) 1 0 LOAD_BUILD_CLASS 1 LOAD_CONST 0 (", line 1>) 4 LOAD_CONST 1 ('A') 7 MAKE_FUN