Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83679
| Date | 2015-01-13 01:43 -0800 |
|---|---|
| From | Albert-Jan Roskam <fomcl@yahoo.com> |
| Subject | Re: class-based class decorator |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17667.1421142513.18130.python-list@python.org> (permalink) |
---------------------------- 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. :-)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: class-based class decorator Albert-Jan Roskam <fomcl@yahoo.com> - 2015-01-13 01:43 -0800
csiph-web