Maric Michaud wrote: > Le jeudi 05 octobre 2006 17:18, [EMAIL PROTECTED] a écrit : >> I guess my solution is slightly less elegant because >> it requires this ugly explicit init call outside the classes that it >> actually deals with, however it is more efficient because the dir() >> pass happens once on module load, instead of every time I want the list >> of exposed methods. > > You can always replace the need of the init method on classes using a > metaclass. > > This demonstrates it with Bruno's expose decorator, but it can be done with > your actual init func too. > > In [6]: class m(type) : > ...: def __init__(self, *a,**kw) : > ...: for name, meth in self.__dict__.items() :
NB : This will only get methods exposeds in this class - not the one exposeds in the parent classes... > ...: if getattr(meth, '_exposed', False) : > ...: print 'exposed :', name > ...: > ...: > (snip) -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list