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
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
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
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
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
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