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


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

Re: class-based class decorator

Started byAlbert-Jan Roskam <fomcl@yahoo.com>
First post2015-01-13 01:43 -0800
Last post2015-01-13 01:43 -0800
Articles 1 — 1 participant

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


Contents

  Re: class-based class decorator Albert-Jan Roskam <fomcl@yahoo.com> - 2015-01-13 01:43 -0800

#83679 — Re: class-based class decorator

FromAlbert-Jan Roskam <fomcl@yahoo.com>
Date2015-01-13 01:43 -0800
SubjectRe: class-based class decorator
Message-ID<mailman.17667.1421142513.18130.python-list@python.org>
----------------------------
On Tue, Jan 13, 2015 6:31 AM CET Ian Kelly wrote:

>On Jan 12, 2015 6:47 AM, "Albert-Jan Roskam" <fomcl@yahoo.com> wrote:
>> Thanks for your replies. I changed it into a regular decorator (not a class decorator). It would have been even nicer if I only needed to specify it once per class, but, well, in my case this hardly matters. The code below works as intended. One problem (not specific to the code): the decorator destroys the signature: it always becomes "*args, **kwargs"). This is annoying with help(), but what worries me most is that my Sphinx documentation is also affected. The information about the defaults gets lost (the parameters are decribed in the docstring, but not the defaults). That kind of sucks. Is there a builtin way around this (in other words: I am aware of this package: https://pypi.python.org/pypi/decorator). I am hoping to get the code working on Python 2.7 and 3.3 and up.
>
>As of (I think) 3.4 pydoc and the help() function will show you the
>signature of the wrapped function as long as you use functools.wraps.
>I don't know what the status is for Sphinx; all I can offer is this
>stackoverflow link.
>
>http://stackoverflow.com/questions/3687046/python-sphinx-autodoc-and-decorated-members

Thank you! Luckily, decorator.py is just one file, so I could easily include it. Version 3.4 is needed, because of a bug in an older version. Now I still need to find out how to create a git submodule to a hg repo, where the decorator package is. :-)

[toc] | [standalone]


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


csiph-web