Re: Registry of Methods via Decorators

2006-06-22 Thread Duncan Booth
Stephan Diehl wrote: > replace '@collect_methods' with '@decorated.collect_methods' > and this will do what you want. That is unlikely as it will keep a single list of methods for all classes derived from decorated: calling decorated.collect_methods will pass decorated as the cls parameter. Wha

Re: Registry of Methods via Decorators

2006-06-22 Thread Stephan Diehl
bayerj schrieb: > I want to make a registry of methods of a class during creation. My > attempt was this > > """ classdecorators.py > > Author: Justin Bayer > Creation Date: 2006-06-22 > Copyright (c) 2006 Chess Pattern Soft, > All rights reserved. """ > > class decorated(object): > > meth

Re: Registry of Methods via Decorators

2006-06-22 Thread Maric Michaud
Hi, Le Jeudi 22 Juin 2006 15:32, bayerj a écrit : > I want to make a registry of methods of a class during creation. Why ? you already have them in dec2.__dict__ : In [42]: import types In [43]: class a : : def b(self) : return : @classmethod : def c(self) : retu

Re: Registry of Methods via Decorators

2006-06-22 Thread Steven Bethard
bayerj wrote: > I want to make a registry of methods of a class during creation. I think you're going to need a metaclass for this, e.g.:: >>> import inspect >>> def registered(func): ... func.registered = True ... return func ... >>> class RegisterFuncs(type): ... def __init__(cls

Re: Registry of Methods via Decorators

2006-06-22 Thread Bruno Desthuilliers
bayerj wrote: > I want to make a registry of methods of a class during creation. My > attempt was this > > """ classdecorators.py > > Author: Justin Bayer > Creation Date: 2006-06-22 > Copyright (c) 2006 Chess Pattern Soft, > All rights reserved. """ > > class decorated(object): > > method

Registry of Methods via Decorators

2006-06-22 Thread bayerj
I want to make a registry of methods of a class during creation. My attempt was this """ classdecorators.py Author: Justin Bayer Creation Date: 2006-06-22 Copyright (c) 2006 Chess Pattern Soft, All rights reserved. """ class decorated(object): methods = [] @classmethod def collect