Basic Types¶
PyGObject will automatically convert between C types and Python types. In
cases where it’s appropriate it will use default Python types like int
,
list
, and dict
.
Number Types¶
All glib integer types get mapped to int
, long
and float
.
Since the glib integer types are always range limited, conversions from Python
int/long can fail with OverflowError
:
>>> GLib.random_int_range(0, 2**31-1)
1684142898
>>> GLib.random_int_range(0, 2**31)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: 2147483648 not in range -2147483648 to 2147483647
>>>
Text Types¶
In case you use Python 2 then text is utf-8 encoded str
, in case of
Python 3 str
is used.
Platform String Types¶
Windows + Python 2: utf-8 encoded
str
Windows + Python 3:
str
Unix + Python 2:
str
Unix + Python 3:
str
Other Types¶
GList <->
list
GSList <->
list
GHashTable <->
dict
arrays <->
list