Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43019
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <arnodel@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.005 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'string': 0.09; 'subject:members': 0.09; 'subject:string': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'descriptor': 0.16; 'docstring': 0.16; 'folks,': 0.16; 'nick': 0.16; 'sentinel': 0.16; 'supplied': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'question': 0.24; 'cc:2**0': 0.24; 'class.': 0.26; 'extension': 0.26; 'header:In-Reply-To:1': 0.27; 'received:209.85.217': 0.29; 'message-id:@mail.gmail.com': 0.30; 'doc': 0.31; 'struct': 0.31; 'url:python': 0.33; 'received:209.85': 0.35; 'received:google.com': 0.35; 'url:org': 0.36; 'received:209': 0.37; 'skip:p 20': 0.39; 'how': 0.40; 'url:3': 0.61; 'to:addr:gmail.com': 0.65; '2013': 0.98 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=INsCd6WSAgmZVBVVkY5BEoJGXJf5+ZI2jLDgvH4jKwU=; b=lpIF9AAghV7e6D0NiTHFYvGZ7tuEeYJw8/5S/c+gW49HbHO+B8T8Dg++86kXK99isd ASN7UGu8b2eUeQTIzPIfpCacWmfVcpGoJmAJ0fGrNr3570cPxbqlJqoO0b4kwylhthnl +YWlWwecmHqzWVkuABuVH1XqcEzh8z3miYVHANeRe/aXtkDtmWmZ/a8EZr+y/eN8AK6R 5TaimTQivWqyS9UQsuSThjB7+AMp9BqZfFK3xq9+tolHZCqF0JHlDC4cMgcd24imfGdQ Bmg1XEZe/YqQkTcPrB8r3JgMG8Y+tdZgZcy5nWNePIttjB5TAj2qsP9pI1OGmmeKwUG8 xciw== |
| MIME-Version | 1.0 |
| X-Received | by 10.112.76.39 with SMTP id h7mr8861957lbw.118.1365366063730; Sun, 07 Apr 2013 13:21:03 -0700 (PDT) |
| In-Reply-To | <5161B4A1.80604@gmail.com> |
| References | <5161B4A1.80604@gmail.com> |
| Date | Sun, 7 Apr 2013 21:21:03 +0100 |
| Subject | Re: __doc__ string for getset members |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| To | Nick Gnedin <ngnedin@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | Python <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.255.1365366070.3114.python-list@python.org> (permalink) |
| Lines | 36 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1365366071 news.xs4all.nl 6914 [2001:888:2000:d::a6]:43112 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:43019 |
Show key headers only | View raw
On 7 April 2013 19:02, Nick Gnedin <ngnedin@gmail.com> wrote:
>
> Folks,
>
> I am writing an extension where I follow the guide on the web
> (http://docs.python.org/3.3/extending/newtypes.html#generic-attribute-management).
> I have an object declared,
>
> struct Object
> {
> PyObject_HEAD
> };
>
> and a member set through tp_getset mechanism,
>
> PyGetSetDef ObjectGetSet[] =
> {
> {"mem", (getter)MemGet, (setter)MemSet, "mem-doc-string", NULL},
> {NULL} /* Sentinel */
> };
>
> My question is - how do I access the doc string "mem-doc-string" supplied in
> the PyGetSetDef structure? If I type
>
> print(obj.mem.__doc__)
>
> then the __doc__ string for the result of a call to MemGet(...) is printed,
> not the doc string supplied in the PyGetSetDef structure.
>
That's not how Python works. You won't be able to get the docstring
of a descriptor this way. You need to do it from the class. The
behaviour you observe is normal and cannot be overriden.
--
Arnaud
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: __doc__ string for getset members Arnaud Delobelle <arnodel@gmail.com> - 2013-04-07 21:21 +0100 Re: __doc__ string for getset members Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-07 21:35 +0000
csiph-web