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


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

Re: class-based class decorator

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2015-01-12 22:31 -0700
Last post2015-01-12 22:31 -0700
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: class-based class decorator Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-12 22:31 -0700

#83660 — Re: class-based class decorator

FromIan Kelly <ian.g.kelly@gmail.com>
Date2015-01-12 22:31 -0700
SubjectRe: class-based class decorator
Message-ID<mailman.17655.1421127132.18130.python-list@python.org>
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

[toc] | [standalone]


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


csiph-web