unsigned short

Thomas Wouters thomas at xs4all.net
Wed Jul 4 10:47:59 EDT 2001


On Tue, Jul 03, 2001 at 05:42:13PM -0400, John wrote:

>     Correct me if I'm wrong:  Python only supports signed short?

Python only has two integer types: Python ints and Python longs. Python ints
are signed longs internally, and Python longs are a custom unbounded Integer
type.

>     I have C function that I'm trying to extend python with by writing the
> corresponding module function.  The C function takes an unsigned short as a
> modifiable parameter.

> If my assumption above is correct, then I need to represent my parameter as
> an integer?  Will this work?  When I extract the python integer to a C
> variable, I would use "i" as the formatter, then cast the it with (unsigned
> short)?  And vice versa for returning a C unsigned short to a python?

You probably want to read up on PyArg_ParseTuple:

http://www.python.org/doc/current/ext/parseTuple.html

You can't convert directly to an unsigned short int, though, so you still
need to cast.

-- 
Thomas Wouters <thomas at xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!




More information about the Python-list mailing list