function decorators

2010-09-28 Thread Nick Donohue
online about what I think is going on, and from what I can tell this code is using function decorators. I guess what I'm asking is if someone could tell me what exactly is going on in this code - how is it different from passing: time_me(some_function(123))? I've tried it this way and it works

Re: function decorators

2010-09-28 Thread Seebs
On 2010-09-28, Nick Donohue ndono...@gmail.com wrote: why would I use these? wouldn't it be more flexible to not write the decorator before the function definition, so I could choose to wrap it or not? The utility is that it lets you modify all calls to a function at once, without changing all

Re: function decorators

2010-09-28 Thread Diez B. Roggisch
some_function(somearg) some_function(arg) I've been looking online about what I think is going on, and from what I can tell this code is using function decorators. I guess what I'm asking is if someone could tell me what exactly is going on in this code - how is it different from passing: time_me

Re: function decorators

2010-09-28 Thread Ian Kelly
@time_me def some_function(somearg) some_function(arg) I've been looking online about what I think is going on, and from what I can tell this code is using function decorators. I guess what I'm asking is if someone could tell me what exactly is going on in this code - how is it different

Re: function decorators

2010-09-28 Thread Terry Reedy
On 9/28/2010 6:02 PM, Nick Donohue wrote: I came across this code just now: def time_me(function): def wrap(*arg): start = time.time() r = function(*arg) end = time.time() print %s (%0.3f ms) %(function.func_name, (end-start)*1000) return wrap @time_me def

Function decorators

2008-09-04 Thread Aigars Aigars
Good day all, I am learning Python and came up to decorators. The question is: Why does function FoodList return value None? The code in attachment. Thank you, Aigars testingVarLogger.py Description: application/unknown-application-x-python --

Re: Function decorators

2008-09-04 Thread Laszlo Nagy
Aigars Aigars wrote: Good day all, I am learning Python and came up to decorators. The question is: Why does function FoodList return value None? The code in attachment. Thank you, Aigars --

Re: Function decorators

2008-09-04 Thread David C. Ullrich
In article [EMAIL PROTECTED], Aigars Aigars [EMAIL PROTECTED] wrote: Good day all, I am learning Python and came up to decorators. The question is: Why does function FoodList return value None? Because the function doesn't return anything, and in Python a function that doesn't explicitly

Re: Function decorators

2008-09-04 Thread Diez B. Roggisch
Aigars Aigars schrieb: Good day all, I am learning Python and came up to decorators. The question is: Why does function FoodList return value None? The code in attachment. Because the __call__ in Logger doesn't return the value of self.func. Diez --