Re: Function decorators

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laszlo Nagy

    Re: Function decorators

    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


Working...