Debian Codegraph @

docs/guide/api/basic_types.rst

raw
1 ===========
2 Basic Types
3 ===========
4
5 PyGObject will automatically convert between C types and Python types. In
6 cases where it's appropriate it will use default Python types like :obj:`int`,
7 :obj:`list`, and :obj:`dict`.
8
9
10 Number Types
11 ------------
12
13 All glib integer types get mapped to :obj:`int` and :obj:`float`.
14 Since the glib integer types are always range limited, conversions from Python
15 int/long can fail with :class:`OverflowError`:
16
17 .. code:: pycon
18
19 >>> GLib.random_int_range(0, 2**31-1)
20 1684142898
21 >>> GLib.random_int_range(0, 2**31)
22 Traceback (most recent call last):
23 File "<stdin>", line 1, in <module>
24 OverflowError: 2147483648 not in range -2147483648 to 2147483647
25 >>>
26
27
28 Text Types
29 ----------
30
31 Text types are mapped to :obj:`str`.
32
33
34 Other Types
35 -----------
36
37 * GList <-> :obj:`list`
38 * GSList <-> :obj:`list`
39 * GHashTable <-> :obj:`dict`
40 * arrays <-> :obj:`list`