Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88998
| Date | 2015-04-15 17:03 -0400 |
|---|---|
| From | Dave Angel <davea@davea.name> |
| Subject | Re: ctypes: using .value or .value() doesn't work for c_long |
| References | <8a777999-f941-4fcf-a924-7a8a804e158d@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.324.1429131838.12925.python-list@python.org> (permalink) |
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 <hint>. 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
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