[BangPypers] Any python metaclasses for UID
Sirtaj Singh Kang
sirtaj at sirtaj.net
Mon Jul 27 11:20:39 CEST 2009
On 27-Jul-09, at 1:50 PM, Shivaraj M S wrote:
[snip]
>
> Can there be a metaclass in python which can change the behaviour of
> object at creation stage by extending it and nullifying friend
> functions?
(I must confess this is the only sentence in the email that I could
comprehend...)
If what you are looking for is a way to customize object creation,
have a look at the __new__ class method. It is called before __init__,
and can return _any_ object when the client code attempts to
instantiate the class.
In some cases I have dynamically generated a subclass of the class
using type(), and returned a new instance of that. I think this is the
kind of thing you are looking for.
-Taj.
More information about the BangPypers
mailing list