Re: [Pyunit-interest] how do i use an unsigned int
Brought to you by:
purcell
|
From: Fred L. D. Jr. <fd...@ac...> - 2001-11-02 22:20:56
|
Yvan Charpentier writes:
> I am calling a C-function that returns an unsigned int
> Python, though, allocate a integer (so i get the wrong value (negative
> number))
>
> How would i force Python to allocate a unsigned int?
This sounds like a general Python question; shouldn't this be
addressed to comp.lang.python?
Anyway, to represent a C unsigned int in Python, you need to use a
Python "long", which can have any integer value. To create this from
a C extension, use this:
unsigned long i = my_function();
return PyLong_FromUnsignedLong(i);
-Fred
--
Fred L. Drake, Jr. <fdrake at acm.org>
PythonLabs at Zope Corporation
|