Re: Decorators not worth the effort

Discussion in 'Python' started by Jean-Michel Pichavant, Sep 17, 2012.

  1. ----- Original Message -----
    > Jean-Michel Pichavant wrote:

    [snip]
    > One minor note, the style of decorator you are using loses the
    > docstring
    > (at least) of the original function. I would add the
    > @functools.wraps(func)
    > decorator inside your decorator.


    Is there a way to not loose the function signature as well ?

    help (t.api.spuAgc)
    > spuAgc(self, iterations, backoffTarget, step) method of ...




    But once decorated with this:

    def stdApi(func):
    @functools.wraps(func)
    def inner(self, *args, **kwargs):
    rsp = func(self, *args, **kwargs)
    result = TncCmnResult()
    result.returnCode = self._getReturnCode(rsp)
    return result
    return inner

    help (t.api.spuAgc)
    > t.api.spuAgc(self, *args, **kwargs) method of ....


    Quite annoying :-/

    JM
     
    Jean-Michel Pichavant, Sep 17, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jean-Michel Pichavant

    Re: Decorators not worth the effort

    Jean-Michel Pichavant, Sep 14, 2012, in forum: Python
    Replies:
    4
    Views:
    221
    Steve Howell
    Sep 15, 2012
  2. Jean-Michel Pichavant

    Re: Decorators not worth the effort

    Jean-Michel Pichavant, Sep 14, 2012, in forum: Python
    Replies:
    1
    Views:
    152
    Steven D'Aprano
    Sep 14, 2012
  3. andrea crotti

    Re: Decorators not worth the effort

    andrea crotti, Sep 14, 2012, in forum: Python
    Replies:
    0
    Views:
    153
    andrea crotti
    Sep 14, 2012
  4. Chris Angelico

    Re: Decorators not worth the effort

    Chris Angelico, Sep 14, 2012, in forum: Python
    Replies:
    2
    Views:
    179
    88888 Dihedral
    Sep 14, 2012
  5. Jean-Michel Pichavant

    Re: Decorators not worth the effort

    Jean-Michel Pichavant, Sep 14, 2012, in forum: Python
    Replies:
    0
    Views:
    163
    Jean-Michel Pichavant
    Sep 14, 2012
Loading...

Share This Page