Hi all,
I need to set some variables via Pysnmp which take 'unsigned int' only.
Is python int by default a 32 bit- signed int? How do I convert it into 16 and 8 bit- unsigned ints? I need to read two registers consequently( which are of 8 bits each) and both of them together give me the desired result.

Can i just convert the result of snmp 'get' into a string, concatenate two strings and later convert it back to int using int()?

any help pls...

Edited 5 Years Ago by novice20: n/a

Is python int by default a 32 bit- signed int?

Python uses the system's, so 32 bit on a 32bit system and 64 bit on a 64 bit system. Note that there is no difference in length between a signed integer and an unsigned integer. A signed integer just uses one of the bits as a sign, so an 8 bit unsigned can store 0-->255, and an 8 bit signed -127-->127 because one bit is used as a sign.

There is bitstring, bitbuffer and bitarray, Also, check PyPi for existing packages whenever you run into a problem like this .

Edited 5 Years Ago by woooee: n/a

In Python integers have a size only limited by your computer's memory. If you want to force compatibility with C you can use Python module struct

This question has already been answered. Start a new discussion instead.