Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88997
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.012 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'attribute': 0.07; 'indicates': 0.09; 'pointers': 0.09; 'subject:using': 0.09; '1:48': 0.16; 'attribute:': 0.16; 'ctypes.': 0.16; 'i.e.,': 0.16; 'object;': 0.16; 'subject:ctypes': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'value.': 0.19; '>>>': 0.22; 'this?': 0.23; 'error': 0.23; 'pointer': 0.24; 'subject: .': 0.24; '15,': 0.26; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'ctypes': 0.31; 'object.': 0.31; 'url:python': 0.33; 'could': 0.34; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'url:3': 0.61; 'more': 0.64; 'details': 0.65; 'url:4': 0.69; '2015': 0.84; 'returns.': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ajxpTqpw0OIu7KrTJp/AsLZbW9vnSFyYSKyMJEyLIqs=; b=naic5vkUP1QZM8jd9Md3LtzISx0sqs9IowhsBEO1kgH15lCnU5NzFE1ClBbrEA1ORn 7DLHeo7VV+7egoEa1AC9+9ZB4g4/vqLRx2sE4GRBj8c7AThdi8CqQrehMj8wj96P6m4C WvIikuGW6YkPuSAdNgzC74DnGd3UbBMWJXawBWO/PrNAdtc2Hk0wbHJlg1yvg3Hd51r7 xOFmayJu15YLnbJ1fYjPWYK+2JSDql3HEC737PoU4pWn+jmSmGG1j3NcEKRG0wVwpgXW r61AQoiHaf0dQz2xJpD/xp4PjFmH0PyGRP8aWuqYJhDV917DVnppzU8CoL2Cu3RimLCZ 4diQ== |
| X-Received | by 10.42.236.132 with SMTP id kk4mr33918247icb.46.1429129988343; Wed, 15 Apr 2015 13:33:08 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <8a777999-f941-4fcf-a924-7a8a804e158d@googlegroups.com> |
| References | <8a777999-f941-4fcf-a924-7a8a804e158d@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 15 Apr 2015 14:32:28 -0600 |
| Subject | Re: ctypes: using .value or .value() doesn't work for c_long |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.323.1429129996.12925.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1429129996 news.xs4all.nl 2949 [2001:888:2000:d::a6]:33825 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88997 |
Show key headers only | View raw
On Wed, Apr 15, 2015 at 1:48 PM, IronManMark20 <mr.smittye@gmail.com> wrote: > I am using ctypes to call a few windll funcions. One of them returns a c_long object. I want to know what number the function returns. > > Problem is, when I try foo.value , it gives me this: > > AttributeError: LP_c_long object has no attribute value. > > Any idea of what could cause this? The error message indicates that this is not actually a c_long object, but an LP_c_long object; i.e., a pointer to a c_long. You can dereference the pointer using the contents attribute: >>> x = ctypes.c_long(42) >>> px = ctypes.pointer(x) >>> px <__main__.LP_c_long object at 0x7fd0812d7950> >>> px.contents c_long(42) >>> px.contents.value 42 See https://docs.python.org/3.4/library/ctypes.html#pointers for more details on working with pointers in ctypes.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ctypes: using .value or .value() doesn't work for c_long IronManMark20 <mr.smittye@gmail.com> - 2015-04-15 12:48 -0700 Re: ctypes: using .value or .value() doesn't work for c_long Ian Kelly <ian.g.kelly@gmail.com> - 2015-04-15 14:32 -0600 Re: ctypes: using .value or .value() doesn't work for c_long Dave Angel <davea@davea.name> - 2015-04-15 17:03 -0400 Re: ctypes: using .value or .value() doesn't work for c_long ethansmithoakland@gmail.com - 2015-04-15 15:18 -0700
csiph-web