Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29380 > unrolled thread

Re: Decorators not worth the effort

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2012-09-17 16:20 +0200
Last post2012-09-17 16:20 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: Decorators not worth the effort Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-09-17 16:20 +0200

#29380 — Re: Decorators not worth the effort

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2012-09-17 16:20 +0200
SubjectRe: Decorators not worth the effort
Message-ID<mailman.834.1347891634.27098.python-list@python.org>

----- 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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web