Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.094 X-Spam-Evidence: '*H*': 0.81; '*S*': 0.00; 'attribute': 0.07; 'subject:using': 0.09; 'windows,': 0.09; 'attribute.': 0.16; 'attributes,': 0.16; 'subject:ctypes': 0.16; 'wrote:': 0.18; 'value.': 0.19; 'print': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'error': 0.23; 'pointer': 0.24; 'subject: .': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'function': 0.29; "doesn't": 0.30; 'especially': 0.30; 'gives': 0.31; 'code': 0.31; 'apparently': 0.31; 'ctypes': 0.31; 'object.': 0.31; 'own,': 0.31; 'class': 0.32; 'says': 0.33; 'url:python': 0.33; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'but': 0.35; 'there': 0.35; 'next': 0.36; "didn't": 0.36; 'url:org': 0.36; 'url:library': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'called': 0.40; 'how': 0.40; 'ian': 0.60; 'url:3': 0.61; "you're": 0.61; "you'll": 0.62; 'show': 0.63; 'charset:windows-1252': 0.65; 'answer.': 0.68; 'received:74.208': 0.68; 'fragment': 0.84; 'presumably': 0.84; 'returns.': 0.84; 'undoubtedly': 0.84 Date: Wed, 15 Apr 2015 17:03:40 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: ctypes: using .value or .value() doesn't work for c_long References: <8a777999-f941-4fcf-a924-7a8a804e158d@googlegroups.com> In-Reply-To: <8a777999-f941-4fcf-a924-7a8a804e158d@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:lGlihrxqOwTt9mDVjUPVrjJV+XJ/Hjgjr9kTwjxmg5la66stz7z zLLQ8S8gU24y0M//l/9uesWhmQwQtpilWVhQ8X9LHLAnybmTWcwkPsa2RfLRq2pO8UiH29K b8aNvfIyRBb5Mcd+wNRoAB0roP4EHoYNYhiiJNqm8/jbRStmZfAglDrzdOUhL3x8/XmCQPL UCLUHCKcfyL5fEJfj/KGg== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1429131838 news.xs4all.nl 2910 [2001:888:2000:d::a6]:43727 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88998 On 04/15/2015 03:48 PM, IronManMark20 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? > I don't use Windows, so I can't try it, especially since you didn't include any code . And apparently whatever function you're using returns a pointer to a c_long, not a c_long. I see Ian has given you an answer. But let me show you how you might have come up with it on your own, for next time. The fragment of the error you include says that the instance of the class LP_c_long doesn't have an attribute called "value". But it undoubtedly has other attributes, so you could look with dir print(dir(foo)) Presumably from there you'll see that you need the 'contents' attribute. Then you print that out, and/or dir a dir() on it, and you see that you now have a value attribute. https://docs.python.org/3/library/ctypes.html -- DaveA