In article <ma*************************************@python.or g>,
Aigars Aigars <sr**@inbox.lvwrote:
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 return anything returns None.
>
The code in attachment.
Thanks for not just pasting it into the post, like so:
class Logger:
def __init__(self, function):
self.func = function
def __call__(self, *args, **kwargs):
print "Function %s called with args = %s, kwargs = %s" %
(self.func.__name__, str(args), str(kwargs))
self.func(*args, **kwargs)
@Logger
def FoodList(a, b, c="spam"):
text = "Food is %s, %s, %s" % (a, b, c)
print text
return text
if __name__ == "__main__":
a = FoodList("eggs", "potatoes")
print a
Thank you,
Aigars---------------------------------------------------------------------
[Image]
--
David C. Ullrich