On Sat, 12 Mar 2005 23:09:58 -0400, vegetax <[EMAIL PROTECTED]> wrote:
>Bengt Richter wrote:
[...]
>> Please pretend things worked the way you want, and post an example. Maybe
>> we can make it work.
>>
>> Regards,
>> Bengt Richter
>
>Ok , the complete use case is :
>
>def fun1(a,b,obj = None):
>
Bengt Richter wrote:
> On Sat, 12 Mar 2005 18:19:36 -0400, vegetax <[EMAIL PROTECTED]> wrote:
>
>>Steven Bethard wrote:
>>
>>> vegetax wrote:
I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:
def de
thanks , i guess the best option is a callable class which builds the
functions with the common code. Once again,we REALLY need a patterns book
for python. =/
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 12 Mar 2005 18:19:36 -0400, vegetax <[EMAIL PROTECTED]> wrote:
>Steven Bethard wrote:
>
>> vegetax wrote:
>>> I i need a decorator that adds a local variable in the function it
>>> decorates, probably related with nested scopes, for example:
>>>
>>> def dec(func):
>>> def wrapper(obj
> What i want is to declare in the decorator some code that is common to all
> these functions, so the functions assume that the decorator will be there
> and wont need to duplicate the code provided by it, and the functions are
> not known ahead of time, it has to be dynamic.
This sounds like a c
vegetax wrote:
Steven Bethard wrote:
Have you considered using OO here? You might find that this is more
easily written as:
py> class Object(object):
... pass
...
py> class fun(object):
... def __new__(self, *args):
... if len(args) == 2:
... obj, b = args
... e
Steven Bethard wrote:
> vegetax wrote:
>> I i need a decorator that adds a local variable in the function it
>> decorates, probably related with nested scopes, for example:
>>
>> def dec(func):
>> def wrapper(obj = None):
>> if not obj : obj = Obj()
>>
>> return func()
>>
>>
vegetax wrote:
I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:
def dec(func):
def wrapper(obj = None):
if not obj : obj = Obj()
return func()
return wrapper()
@dec()
def fun(b):
obj.desc = 'marke
I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:
def dec(func):
def wrapper(obj = None):
if not obj : obj = Obj()
return func()
return wrapper()
@dec()
def fun(b):
obj.desc = 'marked'
obj.