Category Archives: C

++ equivalent in python


by Daniel Stutzbach

Python doesn’t support ++, but you can do:

number += 1



by Thomas Wouters

Simply put, the ++ and — operators don’t exist in Python because they wouldn’t be operators, they would have to be statements. All namespace modification in Python is a statement, for simplicity and consistency. That’s one of the design decisions. And because integers are immutable, the only way to ‘change’ a variable is by reassigning it.

Fortunately we have wonderful tools for the use-cases of ++ and — in other languages, like enumerate() and itertools.count().


Answers on this page are Stack Overflow user contributions licensed under CC BY-SA 3.0

int8_t to uint8_t in Python

A quick and dirty int to uint8 converter in Python.

C – Types – uint8_t, uint16_t, uint32_t and uint64_t

Type Bits Bytes
uint8_t 8 bits 1 byte
uint16_t 16 bits 2 bytes
uint32_t 32 bits 4 bytes
uint64_t 64 bits 8 bytes

The fixed types uint8_t, uint16_t, uint32_t and uint64_t are equal respectively to (in most cases depending on the platform & compiler): unsigned char, unsigned short, unsigned int and unsigned long long.

The fixed types were introduced to be just that, fixed types independent of the platform.