Function decorators

Laszlo Nagy gandalf at shopzeus.com
Thu Sep 4 11:52:38 EDT 2008


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
> ------------------------------------------------------------------------
>
> --
> http://mail.python.org/mailman/listinfo/python-list
First of all, you should always inherit from "object" whenever it is 
possible.


Then the answer:  you did not return the result.

Instead of

                self.func(*args, **kwargs)

use this:


                return self.func(*args, **kwargs)

Corrected example attached.

Best,

   Laszlo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.py
Type: text/x-python
Size: 505 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080904/5fdc01a3/attachment-0001.py>


More information about the Python-list mailing list