[Tutor] unsigned int or char equivalent in Python?

Alan Gauld alan.gauld at btinternet.com
Tue Feb 4 15:50:34 CET 2014


I'm playing with some bit twiddling code at present and started
to get some unexpected results which i eventually realized
were down to Python ints acting like signed ints in C (but
with a 'flexible' sign bit!)

This led me to wonder if there is a way to get unsigned type
behaviour in Python?

This could be very useful in bit twiddling scenarios, especially
now that Python is being used on RasberryPi type devices to
control Arduinos and the like. I had a quick hunt in the docs
but couldn't think of a way to fake it.

Any ideas?

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list