Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Neil Cerutti Newsgroups: comp.lang.python Subject: Re: Class construction Date: 22 Oct 2013 15:48:46 GMT Organization: Norwich University Lines: 21 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: individual.net LGmSCoo9utvHBjrJnRuORAckBPxF5ryX9ug2qE+LKrM/qwO5Nw Cancel-Lock: sha1:ZvwR6PIR3n8WVv9CK6BoXux7j2A= User-Agent: slrn/0.9.9p1/mm/ao (Win32) Xref: csiph.com comp.lang.python:57268 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, namespace > (when you instantiate any class in Python, metaclass is just > a class, first its __new__ method is called, and then its __init__) > > All this is in builtin__build_class__. In addition, the Python manual describes the process in detail. See The Python Language Reference 8.7 Class definitions. Here's a link to the 3.3 version of those docs: http://docs.python.org/3.3/reference/compound_stmts.html#class-definitions -- Neil Cerutti