On Sat, 22 Dec 2007 23:01:50 -0700, Steven Bethard wrote:

> Steven D'Aprano wrote:
>> When you call a new-style class, the __new__ method is called with the
>> user-supplied arguments, followed by the __init__ method with the same
>> arguments.
>> 
>> I would like to modify the arguments after the __new__ method is called
>> but before the __init__ method, somewhat like this:

[snip]

> You can really only achieve this by writing a metaclass.  When a new
> object is created, what's first called is the __call__ method of the
> type object.  This basically looks like::

[snip]


That's an excellent explanation of how to use metaclasses!

Thanks Steve, and everyone else who answered. I'm not yet sure if that's 
the approach I'm going to use (I may end up moving all the instance code 
into __new__, or __init__, rather than splitting it) but that's an 
interesting option for me to explore.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to